Questions tagged [nodes]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
146 views

How to modify field value in other nodes after node update?

After node update I need to modify a field value in several connected nodes. As I know, I cannot use hook_entity_update() since $node->save() forms infinite recursion. How can I modify node fields ...
2
votes
1answer
30 views

Reasons for using a webform node rather than just linking directly to the webform [closed]

Other than reuse, is there any reason why I should not link directly to a form in Drupal 8? I mean linking directly to the webform rather than to a node that incorporates the webform?
0
votes
1answer
33 views

How to create arguments in path with regular page node instead of module, yet pass them to a module

I know how to create a URL with hook_menu() in a module, but is it possible outside a module? Here's what I'm needing/asking: My front-end guy wants to create a page as a node using a Content Type via ...
0
votes
0answers
28 views

How to execute migration on selected nodes thru core bulk action plugin?

I'm trying to execute migration to create a copy of selected content nodes to other content type. Migration source (plugin: content_entity) is content_type_a and destination (plugin: entity) is ...
0
votes
1answer
63 views

Can't update nodes / node unpublishes itself

This problem has been bugging me for some time now and I haven't been able to find this issue online anywhere else. My Drupal 7 website has a very simple photo gallery, using a custom node type called ...
0
votes
1answer
85 views

hook_node_access() doesn't work for anonymous users

I am still unable to understand what hook_node_access() does. I am trying to give view access to the Basic content type nodes to anonymous users, but the code I wrote doesn't work, as anonymous users ...
2
votes
0answers
51 views

Automate notification to Mailchimp

I am trying to automate a notification integration between Drupal8 and Mailchimp. I currently the Mailchimp module installed and a signup form has been configured so that people can signup for ...
0
votes
2answers
34 views

Map array of node IDs to bundle types without loading all the nodes

For complicated reasons I need to map an array of node IDs to a list of node bundles. That is, for a given list of node IDs, I need to get all the different bundles (node types) of the nodes the IDs ...
0
votes
0answers
14 views

How to update value of single field of same node using node_save?

The problem statement: I have one content type called 'Employee' which has 10 nodes. I have to perform the voting for each node. I am saving the vote count in the field called 'vote count'. But when ...
0
votes
0answers
31 views

Why do I see the node ID on the menu URL instead of the path alias?

I created different menus and need them to be displayed in a node based on the language currently visited for a specific node type. Via my theme.theme, I added the following code to retrieve the menus:...
0
votes
1answer
81 views

Editable table column data

In drupal 8, I am writing a custom module and in one of the function in controller -I am fetching data from an external API, then displaying it in table format using - foreach($rec as $data) { ...
-1
votes
0answers
70 views

How do I get all articles from the database? [duplicate]

i am new on Drupal 8 ,in my case i want to get all articles from database filtered by name i have done dome code but it doesn't work for me can anyone help me please ? public function getArticles(){ ...
0
votes
0answers
68 views

What’s the right way to create a Webform node when adding a webform?

I am new to Drupal. I want to create a Webform node when adding a webform. I used the code snippet in https://www.drupal.org/docs/8/modules/webform/webform-cookbook/how-to-automatically-create-a-...
0
votes
2answers
396 views

Load the node as EntityInterface not NodeInterface

hook_node_insert(NodeInterface $node) gets a NodeInterface parameter. I need to pass it to mymodule_node_operations(EntityInterface $entity) which accepts an EntityInterface parameter. How do I load ...
0
votes
1answer
37 views

Altering (adding) field value when is unknown

I have three content types (A,B,C). A and B have title, author, and field_version (a custom field), while C doesn't have field_version. Let's assume I have a method that gets the version value from a ...
0
votes
1answer
277 views

How can I hide fields by user role when viewing a node?

I have managed to hide certain fields for certain roles programmatically in Drupal 8 using function module_name_form_node_form_alter(array &$form, FormStateInterface &$form_state, $form_id). ...
0
votes
1answer
326 views

Inline entity form module fails when creating a new node and the reference method is Views

I have a Drupal 8, core version:8.8.x project, i'm using inline entity form module(latest version) for entity reference fields. Also i have tried using entity connect module but it caused various ...
0
votes
2answers
581 views

Get path alias of node on presave

I was trying to get the path alias using for nodes using the following code. \Drupal::service('path.alias_manager')->getAliasByPath('/node/' . $nid); It works for nodes that are already created, ...
0
votes
2answers
83 views

Why does node_access_view_all_nodes() return true for anonymous users?

On a Vanilla Drupal install (tested on D8 and D9), this will print "1": drush eval 'echo node_access_view_all_nodes() . PHP_EOL;' Stepping through the code reveals that it happens because there is a ...
1
vote
1answer
28 views

separate the page title from page content

I am using {{ page.content }} to print all my page content. It is printing my all content but I want to remove title from this content and print it separately in different div structure (without using ...
1
vote
0answers
50 views

How can I merge nodes from two sources into one render array?

So I've got a bit of a unique situation and I'm curious if anyone has any input. Summary:  I'm trying to figure out how to render 3 nodes from two different sources: 1st Source: A field of type ...
2
votes
1answer
156 views

How can I track how embedded media is used across my site?

My site uses the core Media module, Entity Embed, and LinkIt to reference media and other entities in various ways. I want to keep track of which media is embedded on which nodes. I tried adding an ...
-2
votes
1answer
229 views

Creating content with a hierarchy

I want to create hierarchical content in Drupal, and I am trying to decide between nodes and terms. What I want to do I want to implement books. Each piece of content may be a book (containing ...
2
votes
3answers
199 views

For content, what are the differences between nodes and terms

I am debating whether to use nodes or terms to store a large amount of content in Drupal. There are a lot of similarities between nodes and terms in Drupal 8/9: Both can add any type of field. Both ...
1
vote
1answer
30 views

Add a "Save" action in local task to a node

I would like to add a new action to local task on node. This new action has to save the current node. I have drupal 8.8.0 I know how to add a new action. But my question is about how to save the ...
0
votes
1answer
170 views

how do I get the parent node of an entity reference node

I have two content types - A and B. For content type A, there are 5 content items - Aa, Ab, Ac, Ad, Ae. For content type B, I have two items Ba, Bb. Content type B has a field that is an entity ...
1
vote
1answer
111 views

Allow comments only for the author of the node

I'm using Drupal 8 for a personal project and I'd like to allow only the node author to post comments. Can you please help? I'm stuck.
1
vote
2answers
55 views

Permission to submit webform only for the author of the node

I'm using webform 8.x for a personal project and I'd like to know if it possible to enable only the author of the node to submit the form. In my project each node is an aquarium, and I am using ...
0
votes
1answer
127 views

Read time value of node in view

I am using Read time module for calculating the read time for each node. Value is getting inserted in the database table correctly. But I didn't get an idea about how can I get this value in view. ...
1
vote
0answers
70 views

How do I set the path alias for nodes imported via RSS feed?

In Drupal 8, I have created nodes of article type using the Feeds module, using a RSS feed as source. How can I create path aliases for each of the imported nodes? I have tried to map source:'item ...
1
vote
0answers
68 views

Show node form on preview page

Is it possible to show node edit form on preview page without need to click on "back to content editing"? If yes, how? Why? I'm migrating a website from older Drupal version and "my" users are used ...
1
vote
1answer
123 views

How do I create content during site installation?

As part of Drupal 8 site install/deploy, I want to create content so that the site is functional and ready to use. For example, whenever I install the site, there should be a home page node created. ...
0
votes
0answers
115 views

Field permission for content type

I need to manage different fields for different roles in a content type. If users enter a value for that field, administrator users can see it but not edit that field; on the same content type, when ...
0
votes
0answers
45 views

I have large gaps in NIDs on my site. Should I clean it up?

So, since I have a little extra time on my hands I’m doing some delayed maintenance on my personal site. You know, removing modules I don’t need anymore, cleaning up taxonomy, etc, etc. There is ...
1
vote
2answers
55 views

How can I hide nodes from view, but open access to JSON:API at the same time?

I would like to use Drupal as a decoupled system, sourcing its content by using Gatsby. Having set it all up, I would like my Drupal nodes not to be accessed by random unauthenticated users so I ...
0
votes
1answer
25 views

Load node by value of a field and update value for another field

I'm trying to load a node by a value in a custom field (field_one) to change the value of another custom field (field_two) on that node. I am using the following code to load the node: $nodes = \...
0
votes
1answer
137 views

Loop through a multi value entity reference field working only on the first selected item

1) I have an entity reference view articles_per_user listing all nodes of type article authored by the current logged in user. 2) On the Article Entity, there is a taxonomy reference field ...
0
votes
1answer
338 views

How to get current language of node in twig?

I have a tranlatable node, and I need to get its translation language. You know, I must to know is current node is in Polish or English. So... below there are my devel dumps from a node in Polish and ...
0
votes
1answer
470 views

How can I programmatically restrict node access?

I'm using Drupal 8 with the nodeaccess module. I'm able to set the node grants with the form. I also have a custom module which imports new nodes. These new nodes should be shown only to certain ...
1
vote
1answer
719 views

How do I migrate the "Created" and "Modified" date fields?

I created a migration script to test this out. This is the code I used. id: article_csv_import class: null field_plugin_method: null cck_plugin_method: null migration_tags: null migration_group: ...
1
vote
1answer
57 views

How can I add all the existing content types into a dropdown list?

In Drupal 8, I am using the Config Pages module to set up a configuration page for a custom module. How can I add all the existing content types into a dropdown list?
0
votes
1answer
448 views

How do I display the date but not the author?

I want articles to show Submitted on without showing Submitted by. The checkbox on Display settings toggles both, not only one of them. Control/modify display settings (author and date) on posts ...
0
votes
0answers
29 views

Count how many nodes have been updated per user

I am using Drupal 8. I have been trying to find how many nodes (count) have been created by each user of my drupal site. Following some excellent (although quite old) threads here and here among ...
0
votes
1answer
52 views

How do I get block relationships for a content type?

As part of a migration from drupal 7 to drupal 8, I currently have a rather original node display method that I'm trying to reproduce to Drupal 8, but without success. Currently on Drupal 7, this ...
0
votes
1answer
58 views

Unable to retrieve checkbox values from a template file

I have created a checkbox option for a field. Category One Two Three Four This is the code I am using. {% for key, item in content.field_room_category if key|first != '#' %} <li>...
0
votes
1answer
108 views

Pre-populate an entity reference field (media image) when creating a node

I am trying to open a node creation form (for example, /node/add/article) and to have an Entity Reference field pre-populated. My field (field_image) is an Entity Reference to a Media of type Image ...
0
votes
1answer
43 views

Deactivate system path

I want to deactivate the system path which comes with Drupal. I've installed the pathauto, so when I create a new page, it automatically changes domain.com/node/12 to domain.com/books/jacks-journey ...
0
votes
1answer
57 views

Trying to list all articles where category field is empty

I have drupal 7 site and I'm trying to listing all articles (with title) and where category field is empty (taxonomy). I'm running this code in my page with ->isNull and without, but not any results. ...
0
votes
1answer
277 views

How do I conditionally add a class to my page title within page-title.html.twig?

I have a boolean field within my Page content type called Hide Title. I need to conditionally add a class to h1's to visually hide them if this field is checked. I have the following within page-...
0
votes
1answer
59 views

In node add, how to upload file using image from clipboard

How can I paste image from clipboard and save into image_field ?

1
3 4
5
6 7
149