Questions tagged [nodes]
The most basic form of content on a Drupal site is a node.
7,555
questions
0
votes
2
answers
39
views
How to add <br> tags to a node title?
Saving a node with a title (main node heading) that includes a <br> tag results in a textual <br> in the node title output.
How to add <br> tags to a node title?
0
votes
1
answer
31
views
Why does removing a language removes body content from nodes in this language?
I have a node in a certain language but I have deleted this language in /admin/config/regional/language and the node body content was removed along with it.
I was expecting that there would be a ...
3
votes
1
answer
138
views
Can I use specific preprocess hooks for a node type or a view mode?
Is there a way, on drupal 10/11, to add custom preprocess hook by bundle or view mode in a theme?
An example: the default preprocess to alter node, in theme, is
function mytheme_preprocess_node(&$...
0
votes
0
answers
36
views
How to get a list of all nodes that have multiple revisions? [duplicate]
Generally, I prevent revisions for all content types, and each node has just one revision. However, I may have made a mistake somewhere along the way; also, I have recently converted the content type ...
2
votes
1
answer
35
views
How to create a node based on the NID of a deleted node?
In the past I have deleted /node/1 but I want to create content in it again instead redirecting from it.
How could I do this in Drupal 10.3.1?
0
votes
0
answers
16
views
Compare workflow/moderation state in hook_entity_update()
We have a content moderation workflow with 'published', 'draft', 'submitted' and 'returned'.
I am trying to detect changes to the moderation state with hook_node_update().
function ...
0
votes
2
answers
91
views
Deprecated EntityBlock module preventing upgrade
I have a Drupal 9.5 site that I am attempting to composerize and upgrade to Drupal10. I created a Drupal10 site in a local environment, copied the site content over, and installed all the Drupal10 ...
0
votes
1
answer
62
views
How do you theme the book module?
I am rather new to Drupal and am trying to understand how the themes, templates, layouts, and fields work.
When editing the content type in the UI on the website for the book type, and "manage ...
1
vote
2
answers
117
views
How to get the title of a referenced entity with `?_format=json`?
I have a site https://www.huytonweb.com/ the front end is in Next.js and the back end is Drupal 10 CMS.
The front end will access the data from the back end using ?_format=json (like https://cms....
0
votes
1
answer
56
views
The node ID for newly created nodes is fetched but the node is not loaded
I have a custom module that loads all my nodes from type demarche_en_ligne, it worked fine for a few years but now when we create a new node it won't load.
For instance I created a new node and ...
2
votes
1
answer
37
views
Where could I see a table of the most viewed nodes?
In Drupal 10.2.4 with Statistics core module installed and node view count activated, I want to see a table of the most viewed nodes like this:
node 1 | alias (if any) | 601 views
node 8 | alias (if ...
0
votes
1
answer
49
views
How can I generate multiple pages, each with a unique URL based off of 1 template?
I have a very specific need for Drupal, but not sure if there is a solution and was hoping someone might know of a module or method that might get me going in the right direction?
My brother is a ...
0
votes
1
answer
101
views
Which is the correct way to create redirects from existing nodes
I was discussing with a friend who usually makes different redirects on his site.
Having an existing and published Node he creates a new Node of the same Content Type and creates a redirect from the ...
0
votes
1
answer
86
views
Use the Node Export module to export nodes with images
My team and I want to use the Node Export Module to export and import nodes that include image fields between environments of our Drupal 10 site. However, when I export nodes, the image fields only ...
-3
votes
1
answer
62
views
Can I put taxonomy tags in a block and if I can, how to prevent them from appearing in a field of a node?
Having the taxonomy tags in a field of a node in the main content block of the Content region, is a problem for me, as I would prefer having them inside a block so to better choose where they appear.
...
0
votes
0
answers
17
views
Theme Drupal comment reply page exactly like comment submitted page
I have created a custom content type 'article' where a custom comment field has been added along with other fields like images, taxonomy terms, etc. In the theme file (page.html.twig) for this content ...
1
vote
0
answers
183
views
Is possible to get the latest default revision of a translatable node?
I'm on D10. The site has a content type, e.g. article, which is translatable and has a standard content moderation workflow (draft, published, archived).
Given a node of that bundle, I need to find ...
0
votes
1
answer
96
views
How get the default language of a translatable node bundle?
I'm on D10. I have a translatable content type, e.g. node, article bundle.
How can I get programmatically its default language code, defined in the settings form?
I've tried
$entity_type_manager = \...
0
votes
0
answers
34
views
Displaying content in draft mode
A view is set up to display a node's contents. The node contains workflow moderation, like the published status.
To make a new change in the content and to preview it, the content is set to draft mode....
-2
votes
1
answer
188
views
How can I avoid a node is crawled and indexed by search engines in the tightest way possible? [closed]
I have a node whose path alias is /example, where I test JavaScript and often share it with fellow JavaScript programmers to consult about how best to do something.
I often need to post the URL for ...
0
votes
0
answers
34
views
Force new revision when updating a node programatically [duplicate]
In a project, there exist about 30K nodes which some data should be changed and new value replace the old one, the code is simple like below:
$question = Node::load($id);
$question->field_is_normal-...
0
votes
1
answer
93
views
How can I get a printable version of a node?
I have a node with a simple article in it (an <H1>, a bit of <H2>s and some <p>s).
If I print this page from the web browser as-is, I will get it with grandiose spacings, Drupal ...
-1
votes
1
answer
72
views
Give all users including anonymous ones the option to add nodes of certain content types to a list like "interested", at least once
I'd like to give all users including anonymous ones the option to add nodes of certain content types to a list like "interested", several times.
The logic is identical to that of a shopping ...
0
votes
1
answer
94
views
How to let users write private letters to me about a node?
I want to let users the ability to write personal letters to me based on nodes they read while letters are stored in the Drupal database itself (no emails involved) and will include these fields:
...
0
votes
0
answers
28
views
Get current node url in a custom block [duplicate]
I'm trying to embed Discourse comments in Drupal, so I'm tryinig tu use this code snippet in a custom block :
<div id='discourse-comments'></div>
<meta name='discourse-username' content=...
0
votes
1
answer
113
views
How do I link to a custom form mode in a (node) tab?
My issue is my form is too big and too slow, with nested paragraphs, media entities and so on, the biggest issue is the metatag-module with its 100s of fields.
So I thought I just add a new form ...
1
vote
0
answers
103
views
Why is "'access content' permission is required" when accessing nodes with _format=json?
After upgrading to D10, authenticated users cannot access /node/{id} rest endpoint and images.
View published content permission is enabled and I can see in the logs that I am authenticated. Clearing ...
1
vote
0
answers
119
views
Modifying a field value in theme_preprocess_node()
I have a content type (exercises) which contains a text field (field_path). In this text field I have a path to a video file.
I would like to retrieve the value of this field in theme_preprocess_node ...
0
votes
0
answers
31
views
Can't save node when fields are altered with entity_bundle_field_info
I have a node called Program, with a large number of fields and a custom node form. Because of the very complex way we're indexing it for search, I have two fields, award_type and award_goal, which ...
0
votes
0
answers
61
views
Title length error
We just started receiving the following error when attempting to add a new content item: "Title cannot be longer than 70 characters but is currently 79 characters long." This happens ...
0
votes
1
answer
42
views
Promotion options not visible to Editor role
I have a "Editor" Role with limited access rights. It can basically only create blog type nodes.
I'd like to expose to them the possibility to make to publish the node to the frontpage via ...
0
votes
0
answers
63
views
View breaks the page output
Has anyone encountered this problem or can at least help me debug it?
The views is displayed as standard if the parameters are specified.
Format:Unformatted list | Settings
Show:Field
If I change it ...
0
votes
1
answer
91
views
How do I sort view results by query order?
In my twig I use {{ drupal_view('slider', 'block_1', '74,84,82' ) }}, how can I make sure the output of this view has the slides in that specific order?
Currently on D9. I've looked around but can't ...
0
votes
0
answers
39
views
Deny access to pages or nodes base from a database table
I was modifying a 2fa module for restricting users to access other account's page (user/%/2fa) which is working.
function custom_2fa_menu() {
$items['user/%/2fa'] = [
'title' => t('...
0
votes
1
answer
196
views
How to have a different hero image per node?
What we want: Users should be able to choose an image, add call to action links, and a few other options when setting up a hero for the specific page they are creating. We have three different content ...
1
vote
0
answers
15
views
How can I add the hero section image in the View to REST_API?
Hello im using Drupal 9.5.9 version. How can I add the hero section image in the View to REST_API?
I have created an api with Rest_API to fetch data from Views I have created. I have no problem ...
2
votes
1
answer
79
views
Is it logical to give a homepage an alias? [closed]
Drupal allows us to give a URL alias to any node (example.com/my-alias). The "Home page" node is not an exception.
Is it logical to give a homepage an alias?
Shouldn't we just keep it "/...
-3
votes
2
answers
154
views
How can I embed PHP code in HTML?
I want to execute few curl commands from my Drupal site using PHP.
Idea is to create a custom content type that accepts php code. I understood from the internet I have to create a file "node--...
0
votes
0
answers
93
views
How can I search for existing nodes with "Text format" = "undefined"?
I've upgraded to Drupal 10 from an earlier release, which used the PHP module (not yet available for Drupal 10). Therefore, I had to uninstall the PHP module before upgrading, leaving the "Text ...
0
votes
0
answers
63
views
Populate field value based on external API response
My custom Drupal 10 module takes the value of an address field submitted by the user during node creation, sends that to an external API, and then fills a taxonomy term reference field based on the ...
2
votes
1
answer
323
views
How can I copy a field to another field?
I have an Article content type for which I want to change the machine name of its fields. I created new fields with a different machine name.
How do I copy the old fields to the new fields?
1
vote
1
answer
57
views
How to access the node/term field-values in a cleaner way?
My code is filled with methods like these to access field values:
\Drupal::entityTypeManager()->getStorage('node')->get('field_name')->getValue()[0]['value'];
\Drupal\taxonomy\Entity\Term::...
2
votes
1
answer
3k
views
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist
I have upgraded drupal 9 to drupal 10 and now while creating a content page or editing the existing content page it is throwing error in error logs
Drupal\Component\Plugin\Exception\...
0
votes
1
answer
380
views
How can I programmatically save node components?
There is a site with number of nodes including layout canvas and site studio components available in a node.
When there will be changes in one of the components (new field added with default value), ...
-2
votes
1
answer
38
views
Is there a way to allow entering a value in a node's field if inserting a new node, but make the field disabled if updating that same node?
I'm using Drupal 7 and I have a standard text field in my Content Type. If the user with role "Standard User" is adding a new node then they should be able to set the Status field text value....
1
vote
0
answers
32
views
How to give ability to create custom NID numbers via API REST post when creating content?
I'm using Drupal 9.4 and I tried to pass in a nid value in my POST via the Drupal api. I'm getting the error:
Response: {"message":"Access denied on creating field \u0027nid\u0027."...
0
votes
1
answer
67
views
How can I overwrite the value of a field in a bundle class?
In Drupal 9 I would like to know if it is possible to overwrite the value of a field in a BundleClass. Looking at the Drupal API, I see that it is common to use either hook_entity_view_alter or ...
0
votes
2
answers
210
views
How do I programmatically assign a new book when a new node is created?
For a given content type, if a new node is created and no book is assigned, I'd like to create a new book and assign the new node to that book.
(some background - that content type is the book cover, ...
-1
votes
1
answer
395
views
Getting old node field value in update hook
Hi I'm using the node update hook in my custom .module file in my Drupal 9 site. I have a field called field_amount. And I was wondering if I can access the old value of that field within my update ...
0
votes
1
answer
423
views
Prevent last updated property from changing when updating node in code?
I have this code that updates a node in a queue worker:
$changed = $entity->getChangedTime();
// Don't update the changed time by
$entity->setChangedTime($changed);
$...