Questions tagged [nodes]

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

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

Convert node ID from string to integer

Retrieve a node based on condition: $query = \Drupal::entityQuery('node') ->condition('type', 'my_content_type') ->condition('title', 'my node title'); $nid = $query->execute(); The result ...
0
votes
2answers
31 views

Change article layout on homepage

I would like to change the layout of articles on my homepage. But I cannot find the template hereof. I've got my page.html.twig, which but that only includes a placeholder "{{ page.content }}&...
0
votes
0answers
18 views

Display taxonomy parent tid of a taxonomy term reference field

On a node template , i am displaying a taxonomy term ( entity ref field ). That taxonomy term has a parent. How can have that info on the html generated , for css purposes ? The field.html.twig ...
1
vote
3answers
66 views

Missing form state values after adding submit function

I added a submit function in the form_alter hook when inserting a node: $form['actions']['save_as_draft'] = [ '#type' => 'submit', '#value' => t('Save as Draft'), '#submit' => ['...
0
votes
0answers
16 views

View with multiple node arguments using an entity reference

We have a node type called: MEETING On Meeting we have a user entity reference called: PARTICIPANTS I create several MEETING's and reference 2 users: USER1 AND USER2 Now I want to build a dynamic view ...
0
votes
0answers
39 views

How can I show/hide node field values the same way items are shown/hidden in /admin/modules?

When viewing a node of a specific type, how can I show/hide the values like in /admin/modules? I want to be able to click on the field title and show or hide the value. Is there a module that can help ...
0
votes
0answers
15 views

Displaying sub content (entity references) of node based only with specific taxonomy

I have been working on a solution that would allow training courses to be created using Drupal 8 as the backbone. I have elected not to use the "Courses" module and am simply using custom ...
0
votes
2answers
61 views

How do you target a specific type of content?

I have the content type (node), article, page, recipe. The code below can be used to flag any type of content. How do you target a specific type of content ? For example I only want to flag the ...
1
vote
1answer
33 views

How do I get the administrator to automatically flag?

I created a module for flagging entities automatically when created or updated. There are some errors in my code because only nodes work. If a user "user1" creates a node, the flag will be ...
0
votes
1answer
46 views

How to properly program AJAX links?

I have a custom module that uses AJAX. Everything works fine the way it is. I'm just wondering if it's the proper way to do it in Drupal. I'm new to Drupal 8 and 9 programming This is a line from my ...
0
votes
1answer
40 views

How to programatically hide node field on viewing?

Using Drupal 9, How do I hide a node field when viewing it? Let's say I have field info. I would like to conditionally not display the label or the value. I assume I use hook_node_view_alter but I'm ...
0
votes
1answer
33 views

How to remove images from body field in views?

In the body field of a content type, I have added an image at the start. In my view, I want to show 200 characters from the body field. It also prints the image. How can I skip the photos from the ...
0
votes
0answers
17 views

Search API autocomplete: How to get Node ID in suggestions?

I am using https://www.drupal.org/project/search_api_autocomplete for autocomplete search results is it possible to get Node ID with suggested results? Thanks
0
votes
0answers
17 views

Get Paragraph's Parent Node Before the Node is Saved in Constraint

I have created a Paragraphs Constraint and I am unable to get access to the parent node's bundle in the constraint because the node has not been saved yet. public function validate($entity, Constraint ...
1
vote
0answers
23 views

Copy a field's value to another field and modify it

I have content type "Video" When i do a new "video" I have a field "iframe_vimeo" thats it contains a value of the iframe's video link. I want to do some modifications ...
1
vote
1answer
15 views

Programmatically setting video_embed_field URL

I am trying to populate nodes programmatically from a feed (migrating earlier site to Drupal 9). So far I have managed to get everything else to move, but I can't figure out, how to set ...
1
vote
2answers
50 views

How to let users allow other users to view specific node content?

I'm using Drupal 9 I would like users to be able to allow other users to view their node content. Ideally a user will request access to view the content and the content owner will grant them view ...
3
votes
1answer
76 views

How can I save an unpublished node skipping required fields validation?

What is the best way to save node without the required field values? It would be something like "save as unpublished" and the required validation is omitted, but I am not sure in which ...
1
vote
0answers
25 views

Node access audit by user?

I have a unique need to log all attempts, with timestamps, by all users to access nodes of a given content type in Drupal 8/9. We wish to use our existing Drupal site to collect submissions of ...
2
votes
1answer
104 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
28 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
32 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
23 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
0answers
26 views

Can I get all the possible values of a field of a content type

I've got a field on a content type that is a taxonomy reference with multiple terms. I'm trying to pull all this values from my custom module config so I can limit my module only displaying on ...
0
votes
1answer
33 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
43 views

hook_node_access() doesn't work for anonymous users

I am new to Drupal 7, I am still unable to understand hook_node_access operation I am trying to give view access to the basic content types nodes for anonymous users but it is not working. It is still ...
0
votes
0answers
14 views

Master view with master node and micro node

I use micro modules to manage a multisite for a french university. I want to create a view for the master site, which contains all master nodes and nodes from micro-sites tagged with "promote in ...
0
votes
0answers
53 views

Content moderation “current revision” not set on nodes migrated from Drupal 7 where there are both a published and draft revisions

I am working on upgrading a Drupal 7 site to Drupal 8. The upgrade uses a content-only custom migration. The Drupal 7 source site and the Drupal 8 destination do not contain any custom modules other ...
0
votes
0answers
30 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
31 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

The admin/content page only shows the Delete button for nodes; missing edit and view

I have created a role in D8 with permissions to add/edit/delete any content type, even if its not their own. They also have the blanket "Administer Content" permission. When they view a node,...
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
25 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
37 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
54 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
21 views

Moving nodes and menus between environments

I've a large menu of basic pages I'm trying to move from my D7 development environment into production. So far I've been trying to use the Node Export module to build a feature. That didn't seem to ...
0
votes
0answers
13 views

How do I show the video preset options when uploading video files in the node edit form?

I am using the Video module with FFmpeg. How do I show the video preset options when uploading video files in the node edit form? Is this possible?
1
vote
0answers
37 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
104 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
0answers
12 views

Display video transcode PRESET options in Node Edit form

I need to be able to expose the video transcoding preset options within Node Edit pages. Currently, the Video module allows me to choose/change the Presets site-wide in Video modules settings page ...
0
votes
1answer
26 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
64 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
105 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
191 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
0answers
15 views

Can a published node have a later unpublished revision?

I haven't used Drupal for a while and I'm wondering whether this has been fixed recently or whether I'm mis-remembering. I believe that if revision X of a node is published, it wasn't possible to ...
0
votes
2answers
43 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
23 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
31 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 ...
0
votes
0answers
22 views

Grouping doesn't work with content type title

I am using Drupal 8. I have a "Unit" content type and "Unit Word" paragraph. I have created the "My Vocabulary" view that shows the "Unit Word" paragraph. Now I need to group records with the "Unit" ...
2
votes
1answer
51 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 ...