Questions tagged [nodes]

The most basic form of content on a Drupal site is a node.

Filter by
Sorted by
Tagged with
0 votes
1 answer
72 views

What is the equivalent of Joomla's {loadposition} and {loadmodule}?

I have recently converted from Joomla to Drupal. I am still learning how to use it but I can't seem to find answers (esp for Drupal 9 not some ancient version usually coming up with google search) how ...
user avatar
0 votes
0 answers
76 views

ckeditor not loading rich text editor by default

I'm running CKEditor 7.x-1.19 with Drupal 7.80. With "Default editor state" set to Enabled, and "Show the disable/enable rich text editor toggle" set to Show, my system is still ...
mts11's user avatar
  • 1
1 vote
0 answers
120 views

How to target the initial revision of a node?

How to target the initial revision of a node? This gives me a list of node IDs in which the latest revision of the node is of author $user->id(): $query = \Drupal::entityQuery('node'); $query->...
Matoeil's user avatar
  • 3,369
-1 votes
1 answer
194 views

Add custom form to content type (Basic Page or any) using custom extesnion

I am new to Drupal. Actually, I have to add a custom form to the content type and it will be visible to the frontend user where they can submit their response. So I have created the form and save the ...
Balwant Singh Sisodia's user avatar
1 vote
1 answer
133 views

Show latest changes in node "View" tab while using Content Moderation

I had been trying a lot to display latest revision into view tab irrespective of its state, so if a node is in "Draft" state I still want it to be displayed under "View" Tab rather ...
Umesh Patil's user avatar
0 votes
1 answer
136 views

How to display the first child of a book with the title of the book and keep the url by using a view

Is it possible to display the list of the first child of every book with a view? I couldn't figure that out so I added boolean to the book content type to check which child is the first child. If that'...
Charly's user avatar
  • 15
0 votes
0 answers
51 views

How to embed image field url in API response?

I have a content type that has a title, body, link, and image field. Then in my php file I have the following: $articles = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['...
Sidney Sousa's user avatar
1 vote
0 answers
82 views

How can I restrict selectable terms in a term reference field to only show those which have been used earlier by the same user?

I have a node (type = List) with 2 fields, Term Name and Body. Body is a long text type field and Term Name is a entity reference field, which is a drop down with a list of Term in Vocabulary Vocab. ...
Neeraj's user avatar
  • 11
0 votes
1 answer
150 views

Get taxonomy field value in forum-list.html.twig

I am customizing the appearance of the forums. I added all my forums and container. Additionally, I added a custom taxonomy field I need to show for each forum category. How can I show the custom ...
C. Riemer's user avatar
0 votes
1 answer
143 views

How to add an article to a page automatically

What I want to do is to add the title and the body of an article I create on my homepage just as you would do it for a news. I've been trying to make this work but I can't find a way to do it without ...
Noivy's user avatar
  • 1
0 votes
2 answers
119 views

How can I copy a body field from one node to another node?

I'm trying to write a small module that copies the body content from one node to another node. The module does almost what it should and everything arrives so far. However, I have to open the node to ...
Bavramor's user avatar
-1 votes
2 answers
103 views

How many child pages can be added under a book parent item?

When using the Book module, is there any limit on the number of child items that can be added to a book parent node?
Abhijith's user avatar
2 votes
1 answer
704 views

how to set a node to anonymous author?

Change node author works : $node = \Drupal\node\Entity\Node::load($nid); $node->set('uid','45'); $node->save(); But i don't know how to set it to anonymous user ? or unset it ? $node = \Drupal\...
Matoeil's user avatar
  • 3,369
0 votes
1 answer
27 views

Block the node which I am currently in

I am discovering one problem on my page - as a content I have some recipe. Under it, I've created a block which is displaying "Simular recipes". And now, this block is displaying some ...
metalac's user avatar
  • 35
1 vote
1 answer
42 views

Implementing hidden content parts (as in old "Hidden Content" module)

There is (long unsupported) "Hidden Content" module, allowing to insert content blocks visible by certain roles only, i.e. like below: [hidden role="Role Name"] ...content ...
Konstantin Boyandin's user avatar
1 vote
2 answers
641 views

user_cancel_reassign() doesn't work when user has more than 10 nodes

I am attempting to delete users with no permissions/roles from our sites. The user's node should be kept. This code works when the user has a few nodes. On deletion, their ownership is passed to the ...
Matoeil's user avatar
  • 3,369
0 votes
0 answers
572 views

How to programmatically update a file uri in a node

I'm programmatically moving a pdf file and then trying to update the uri in the node. Here's my code: $node = \Drupal\node\Entity\Node::load($nid); $entity = $node->field_pdf->entity; if ($...
Marshall Morrise's user avatar
2 votes
2 answers
221 views

How to expand NodeForm so new argument can passed to it

I have a content type called service request, which have some conditional fields that each might appear or disappear based on an other field value called service type. I have used conditional field ...
Alireza Tabatabaeian's user avatar
0 votes
0 answers
112 views

API to get a content type against URL

I have a scenario where I need to perform some redirection of a not found url http://localhost/drupal9/node/1/search the word search is added though a plugin I am using and it is a front-end route ...
uneeb meer's user avatar
1 vote
2 answers
436 views

Is there a way to find internal links to a specific web page?

For example, for a page called mysite.com/about can you determine any other pages that link directly to this web page? The goal is to determine all of the webpages that exist in mysite.com that have a ...
Patrick's user avatar
  • 11
1 vote
1 answer
324 views

Create link to node in specific language

So I need to create links to specific translations of a node but am having issues. This is my code: foreach($entities as $entity) { $urls[] = Url::fromRoute('entity.node.canonical', [ 'node' =&...
lordZ3d's user avatar
  • 358
0 votes
1 answer
123 views

Node hits getting cached for anonymous user

We are using Drupal 8.8.5. For every page we are trying to provide a counter which increments whenever user hits that node. These are nodes are available to anonymous users. So whenever an anonymous ...
bikramjit naha's user avatar
0 votes
2 answers
247 views

How do I delete all book page nodes, book outline, and uninstall book module

I would like to remove a book, its contents, its outline, and uninstall the book module itself. I deleted all the "Book page" content type nodes. I then deleted the one book listed under: ...
edg's user avatar
  • 153
0 votes
1 answer
1k views

Is it possible to alter html_head using hook_page_attachments_alter() per node?

Is it possible to alter html_head using hook_page_attachments_alter() per node? I need to attach different <script> tags to a list of nodes. I am able to add it to each node, but all gets ...
Philip Park's user avatar
0 votes
0 answers
39 views

Form doesn't update via hook in edit mode, instead of it page reloading

This is not happening all time (possibly for big amount of existing field, I'm not sure, with less amount of fields form is saving as it should) when I'm adding new Field collection entity or update ...
Vlad Gulyaev's user avatar
1 vote
0 answers
2k views

Programmatically add a node

Some years ago I made a Drupal 7 site. I want to remake the site with Drupal 9. In Drupal 7 I added nodes programmatically with this PHP code. define('DRUPAL_ROOT', getcwd()); require_once DRUPAL_ROOT ...
Anna's user avatar
  • 11
0 votes
1 answer
72 views

When updating or creating a node of a specific type, I want to save a PDF version into files

I have a node of a particular type that I would like to save as a pdf file (using Entity_print) upon creation or update (whenever a content is saved). The issue I am running into is that some of the ...
Chris Howell's user avatar
1 vote
1 answer
88 views

Create basic field data in template like node for custom entities {{ custom_entity.id }}

I see node preprocess does this $variables['node'] = $variables['elements']['#node']; and then in the template one can do this {{ node.id }} but when I create a custom entity and do the same, I never ...
Dylan's user avatar
  • 428
1 vote
1 answer
35 views

How can I avoid users can change the "Make revision" field?

My users can edit any content, but I really need to know what they did. I need revisions. I tried the Hide revision module, but when the Make revision field is unchecked, the revision isn't created. ...
Roman's user avatar
  • 21
1 vote
1 answer
62 views

Editing a node deletes body content reproducibly if Locale module enabled

I am experiencing a pretty serious problem leading to data-loss in D7. Editing any existing node leads to empty body content and newly created nodes have no body content whatsoever. Update: The error ...
Michael's user avatar
  • 381
0 votes
1 answer
155 views

Twig template for content in body

I want to put some custom information in the content area of book pages (so, after the author info and before the add child page, etc. links). In the node template, the content comes in with both the ...
Chanel's user avatar
  • 95
0 votes
1 answer
121 views

Users chosen from a field in a content type see only their result

I have a list of students who are users in my Drupal 8 site. I want to publish their result but I want each student to see only his/her result. I have a content type where I can get marks and an ...
Pankhuri Singh's user avatar
1 vote
0 answers
367 views

Fetching breadcrumb in search result list

I am trying to get the breadcrumb, for nodes in search result listing. I came to know that breadcrumb by default fetches the current node context, so I followed the suggestion from here - How do I ...
Amit's user avatar
  • 29
0 votes
0 answers
353 views

How do I add an active class for a views row?

I have a view block that lists different nodes. If I am viewing the block on any of those pages I'd like to add an .active class (or at least some kind of identifier) to highlight it with CSS as a ...
Lenny's user avatar
  • 214
0 votes
0 answers
172 views

Rabbit Hole redirects not working for admin

I have a problem with Rabbit Hole redirects. I've set rabbit hole redirect for a content type, saved it, cleared cache. The problem is that the redirects work only for anonymous users. When I am ...
sailormoon's user avatar
1 vote
1 answer
40 views

Filter by text of a field of an entity displayed in a view

I have following content types: "Person" and "Publication" and I'm showing the publications using a view on a page, showing title, year, venue and authors. The authors in "...
mtnair's user avatar
  • 63
0 votes
1 answer
878 views

How can I insert fields from custom content to custom form?

I have a problem with form. I had to create a custom content with fields. User can put variables into those fields and save to database, for example "Anna" into column field_student_name in ...
newbe's user avatar
  • 5
0 votes
1 answer
713 views

How can I have default field values for the node add form as arguments in the URL?

I have a path in drupal 6, which allow me to add new content with 2 fields completed. For example, path node/add/my_content_type/4/6 means that I am on page /node/add/my_content_type, and first field ...
newbe's user avatar
  • 5
1 vote
1 answer
153 views

Is it possible to dynamically select between two different template files for the same content type?

We are rolling out changes on a content type with a new theme and field structures for existing content. Is it possible to dynamically select one of two template files for a content type? For example, ...
quantumized's user avatar
  • 1,187
0 votes
1 answer
166 views

How do I manage breadcrumbs when the node uses multiple vocabularies?

I have a blog in Drupal 8 and it uses the Categories vocabulary to display breadcrumbs as Home > Blog > [Category] > Post title. I added taxonomies from the Tags vocabulary, which means every ...
bdereta's user avatar
  • 141
1 vote
1 answer
353 views

How to display a node edit form in custom URL

I have a node created (using Default content) as part of the site install and it is available to edit at node/[nid]/edit. However, this node holds some of the site-specific content (for example, ...
vijaycs85's user avatar
  • 2,384
0 votes
1 answer
43 views

Render published content or comments on new created content using a link

I was looking without luck for a way to be able to make a link or button with the functionality of making a new content showing some content or comment already posted above, something like the Retweet ...
MrIssue's user avatar
  • 75
-2 votes
1 answer
87 views

Linking two different views for the same content type

I have a content type with around 50 fields with three groups A,B and C(grouped in views). I have a view which shows the new content added in table format(limited fields). I do not want the table to ...
Pankhuri Singh's user avatar
0 votes
0 answers
28 views

Is there a way to ouput variables in a custom module?

I'm updating a custom module and I would like to output the $node and $user variable to see what is in it for a specific key. The value of this key can be one or multiple strings and I'd like to know ...
FonsVC's user avatar
  • 111
0 votes
1 answer
230 views

How do I change the node title when saving it?

For a content type (Article), when I create a new node and save it, I want to append a field value (for example, Location) to the node title. There seems to be great answers using custom plugins (...
Cortex's user avatar
  • 101
0 votes
1 answer
129 views

Change parent of multiple child pages

I have a page with many child pages. And I have a task: there's needed to change parent for all of this child pages. I can move single page using "node hierarchy > Parent > Enter the title ...
Andrew Louis's user avatar
0 votes
1 answer
1k views

How to fix this error about the Node class not found?

I've installed Drupal 8, I've created a PHP file to read a XML file and insert some items, but I'm getting this error. Fatal error: Uncaught Error: Class 'Drupal\node\Entity\Node' not found in C:\...
skycomputer2's user avatar
1 vote
2 answers
169 views

Limit the number of nodes created from anonymous users

I am in the process of finishing the development of a small appointment scheduling system, just using node creation as an appointment. Anonymous users can thus make appointments via a node creation ...
Seldell's user avatar
  • 40
-2 votes
1 answer
57 views

How do I show a confirm dialog in hook_node_validate()? [closed]

I want to check a integer field value in a node add/edit form, if the value is greater than 10, I need display a JS confirm dialog "Are you sure your *** is greater than 10?", if user click ...
Vincent's user avatar
1 vote
0 answers
50 views

Select nodes that share some of the same tags, and sort by tags in common count

I have nodes that can have many tags. I'm able to display nodes that share some of the tags. $query = \Drupal::entityQuery('node'); if ($nodeId != null) { $query->...
gkpo's user avatar
  • 279

1
3 4
5
6 7
151