As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [nodes]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
26 views

Which hook is invoked after an endpoint creates a node?

I am using Services 7.3x with Drupal 7. I have setup an endpoint that creates nodes. After a node is created by the endpoint, I would like to retrieve some data from the new node and update a third-...
Charlotta Beavers's user avatar
0 votes
1 answer
50 views

How to use the user profile photo as the default image in a content type image field?

I would like to pull the current user profile photo in a content type image field but the default image option only allows the admin to choose an image file. Is there a module that allows the admin to ...
CocoSkin's user avatar
  • 859
0 votes
0 answers
16 views

Adding markup to field during programmatic creation of node [duplicate]

I'm programmatically creating nodes but I've noticed when I add formatted text to its body field it's escaping all the html. I'm supplying the field with a markup object but it still just treats it ...
Matt's user avatar
  • 5,482
-2 votes
1 answer
239 views

How do I get a node by its ID?

Using {{ drupal_entity('node', '123', 'body') }} in a template file, I can get the node body and title. Is there a way to get all the available node properties?
2 votes
2 answers
450 views

How to completely change node/entity rendering to my own render element using hook_entity_build_defaults_alter()

I want to interrupt the normal entity view build process for certain content type and view mode combination, and use a custom render array instead of the default node builder render array. I can ...
Dave Reid's user avatar
0 votes
1 answer
41 views

REST edit multiple relationship field

I'm developing a telegram bot and I'm using a Drupal site to manage data. From my bot php code I create some nodes like this: $url = "/entity/node?_format=hal_json"; foreach($obj['...
Shyghar's user avatar
  • 1,074
0 votes
1 answer
444 views

Update the text format and process the body field of existing nodes programmatically

I am trying to resave a number of nodes to apply the text format changes to the body field. I’ve written a drush command to do this. The command does update the text format, but the text in the body ...
tnum's user avatar
  • 21
0 votes
0 answers
98 views

How can I add a pager to \Drupal::entityQuery()?

We are trying to add a pager using the pagerer module for a list of nodes. The aim is to list tagged articles in a tag page, but it doesn't work. It returns null. When we dump the data without the ...
RaghdaHussein's user avatar
0 votes
1 answer
25 views

How can I reference imported content types?

I have imported two content types. One is for a vendor list and the other is for a contact list. The vendor list was imported with a vendor id column. The contact list was also imported with a vendor ...
Sean Magula's user avatar
1 vote
1 answer
40 views

Call to undefined function flag_get_flag() with Flag 4.x

I'm using the 8.x-4.0-beta3 release of the Flag module in a custom D9 module to flag a newly programmatically created node using a flag I created in the UI. $flag = flag_get_flag('new_call'); $flag-&...
Riley Lutz's user avatar
1 vote
1 answer
822 views

How do I programmatically add images to a node?

I have a content type to which I added an image field. The database has a custom table with different columns, including the image ID. Previously, I created a batch that writes data from this table to ...
erik's user avatar
  • 21
0 votes
0 answers
54 views

REST API : how to post a content in multiple langage

I'm trying to POST a multilingual content like this : POST : $URL/node?_format=json { "type": [ { "target_id": "movie", "...
Eric STOCLET's user avatar
1 vote
0 answers
56 views

Message subscribe module don't send emails

I'm working on a project where I have to notify users when a new node is published or a new comment is created. To achieve this, I've installed the Message subscribe module. I've configured few flags ...
Newbiedev's user avatar
1 vote
0 answers
55 views

Define a role to only save drafts even when editing published content

I bet this is a nerd doubt (sorry) but after searching all I find are more complicated/advanced questions and not 'the basic one'. I'm creating a 'basic editor' role that can send content (node) that ...
hip's user avatar
  • 17
1 vote
1 answer
108 views

How to put fields created with BaseFieldDefinition::create() within the advanced group on node edit pages?

I am wanting to create some fields for a few of my existing content types but not sure how to go about it. Currently I am creating fields like this function HOOK_entity_base_field_info(...
Joseph's user avatar
  • 13
0 votes
1 answer
89 views

Toggle (show or hide) visibility of content type field in view depending on relationship with other content type

I have a member content type that displays info about a company's member. One of the fields is named member publications, and it's a link to a blog view where the publications of the member (another ...
Gabri's user avatar
  • 3
0 votes
0 answers
174 views

How to bulk-change a text format?

I should paste much article content in Drupal in nodes. The output data I paste has much HTML in it. I need to paste the data without HTML at all so I thought about bulk-changing the content-type's ...
alkomosi's user avatar
2 votes
1 answer
70 views

Display local actions only on nodes of given type

I have defined a local action in my_module.links.action.yml. I have defined, that it should be displayed on a single route appears_on: entity.node.canonical. - And it works fine. Now I try to achieve, ...
Joachim Feltkamp's user avatar
-1 votes
1 answer
78 views

How to restrict access to a specific node to to an individual user

I am trying to see if I can put together a D9 site for this person how designs custom 3D images and animations. I'm working on a way to have him sell the files once completed, but first I need a way ...
TomP's user avatar
  • 93
-4 votes
2 answers
50 views

Embedding a text chunk in the text-area of two or more nodes [closed]

I wish to embed the same text chunk inside the text-area of two or more nodes. One possible way is to call a node of content type B inside the relevant nodes of content type A by HTML iframe but ...
user avatar
0 votes
1 answer
240 views

How to call a token directly from the WYSIWYG editor?

I wish to call a token directly from the WYSIWYG text editor of a node of a certain content type. For example, I wish to call the token [current-page:title] (node H1 tag) from the edit page. So, for ...
meta's user avatar
  • 3
0 votes
0 answers
131 views

How to make entity query condition field case insensitive to compared value

I am writing an entity query as below $entity_query = \Drupal::entityQuery('node'); $entities = $entity_query->condition('my_field', 'some data', 'LIKE') ->condition('another_field', ...
Sharique's user avatar
0 votes
0 answers
55 views

How do I display the content type name (not a machine name) and their quantity that is on the website on the page?

I have 2 content types(nodes) on the website: Blog and FAQ. I need to display the name of the content type and how many nodes of those content types are present on the site, on two different lines. ...
bill's user avatar
  • 9
0 votes
1 answer
35 views

Anonymous users can edit all anonymous users content

Drupal has a edit own content permission for each content type. I have given the Article: edit own content to anonymous users and discovered that Drupal doesn't differentiate between different ...
Tasha Jordan's user avatar
0 votes
0 answers
25 views

Pull value from a node field based on another field

I want to be able to update the value of a field based on taxonomy term. I have a term (location) with a custom field (country) and city with corresponding values in this term. I create a reference ...
Elorm's user avatar
  • 1
0 votes
0 answers
33 views

How do I create a block that displays nodes related to the current page?

I have a taxonomy vocabulary (Tags) with the following terms. term 1 term 2 term 3 term 4 term 5 term 6 term 7 term 8 term 9 term 10 term 11 term 12 term 13 term 14 term 15 term 16 I have an ...
Mathieu's user avatar
  • 11
0 votes
0 answers
109 views

How to display nodes that belong to the same taxonomy term as the current page?

I created a "Categories" taxonomy vocabulary with the following terms and child terms : - Crypto -- Binance -- Ledger -- Metamask - Geek -- Security -- Apple ... The "tags" ...
mathieu's user avatar
  • 25
0 votes
1 answer
173 views

Run hook_preprocess_node only for main page

Is it possible to run hook_preprocess_node() only for the main page, and not for the referenced nodes that are on that same page? I am using the following code, but it doesn't feel like the best ...
Joost's user avatar
  • 1,078
-1 votes
1 answer
160 views

Add paragraph value to referenced node [duplicate]

I have a paragraph with two field: Paragraph title [text field] Node [entity reference field] The node is displaying its title and an image. By default the Node title is a H2 heading. But I want it ...
Joost's user avatar
  • 1,078
0 votes
2 answers
90 views

Title fields are displayed as a link

For me, all referenced fields or all title fields are displayed as links. This fits in the node as well as in views. However, I don't want this at all, but I would like these fields to be displayed ...
Bavramor's user avatar
0 votes
0 answers
127 views

How to show summary of a node in CKEditor?

I have a website built with Drupal 9. I publish many articles on it and I would like to display in my articles, the summary rendering entity of other articles related to my writing. I know this is ...
zoulou66's user avatar
0 votes
0 answers
572 views

Twig Tweak 3 and drupal_field in node twig template

I have a Drupal 8 site with Twig Tweak 2 which I've upgraded to Drupal 9 with Twig Tweak 3. This has broken a custom node twig template. With Twig Tweak 2, this worked: {{ drupal_field('...
Chanel's user avatar
  • 95
0 votes
0 answers
12 views

Hide only one field from view for empty contextual filter

I have a view with the following structure: Here's the response in close-up: My requirement is to hide thecontent field for an empty contextual filter value i.e when we call /sync/newslist. The ...
Mathew Dony's user avatar
1 vote
1 answer
355 views

Use path alias as contextual filter

I have nodes in Drupal for News Articles that generates this automatic URL alias. I also have a view for News nodes. This is the data. The problem is that I can't use Content: Path (url) or Content:...
Mathew Dony's user avatar
0 votes
0 answers
141 views

How do I pass a variable to a template file?

I have a template that defines a module that builds a paragraph. This paragraph uses a field reference to link another type of content. In my main paragraph I call this reference content with {{ ...
bem22's user avatar
  • 101
0 votes
1 answer
173 views

How can I update the node date for all nodes

I have imported a number of nodes to a fresh installed Drupal 9. Later, the original content creation date (from the previous website) became important. I have the information according to the new ...
loker's user avatar
  • 15
0 votes
0 answers
142 views

Programmatically attach an image to a field

I am using Drupal 9.3.13 on localhost. I generate successfully a QR Code based on the .SVG format and store that image on public://. I created various field types, one of which is a field_file_svg ...
mariosdaskalas's user avatar
1 vote
0 answers
94 views

Sending data to custom block [closed]

I created a module that has several pages of administration. One of these pages is a block creation page. When the block is created the name of the block is kept in the database. The block build() ...
cjobes's user avatar
  • 11
1 vote
1 answer
132 views

Method getTitle() returns an unexpected value. What causes this?

In an implementation of hook_node_insert(), I have the following three lines of code: dpm($entity, 'entity'); $title = $entity->getTitle(); dpm($title, 'title'); From the first dpm() I get: entity ...
Free Radical's user avatar
-1 votes
1 answer
29 views

Unable to add newly created term to the node

I want to add new taxonomy term to group of nodes that have specific terms already. To retrive them I use this function function getNodesByTaxonomyTermIds($termIds){ $termIds = (array) $termIds; ...
Nafai's user avatar
  • 1
0 votes
1 answer
67 views

How to put a phone number in one place and call it from various other places? [closed]

Let's say I want to store my phone number in some "Drupal variable" and then call it anytime I need it, in, say, a node or a block. The purpose is not the repeat the phone number and change ...
phoner's user avatar
  • 15
0 votes
2 answers
253 views

Access Denied for programmatically added file to a node

I have a custom script that imports contents from an external database. I'm attaching files using the below custom code. $file = File::create([ 'filename' => $new_filename, 'uri' => $...
robdex's user avatar
  • 11
-2 votes
1 answer
416 views

502 Bad Gateway on editing or creating only for one content type

Drupal 9 project. I can create and edit all content types but one. I get a 502 Bad Gateway from Nginx. Theese are the logs: 2022-05-05 10:39:11 Error ***.**.***.*** 503 GET /node/6095/edit?...
fombo's user avatar
  • 11
2 votes
2 answers
304 views

Node ID caching on hook_form_alter()

I have a webform with an email field. I am embedding the webform on each node, with a field on the node for the email address. I implemented hook_form_alter() in my .theme file that loads the node ...
Stephen Ash's user avatar
1 vote
1 answer
147 views

How can I disable revisioning on specific node field

I currently use hook_entity_extra_field_info() and hook_ENTITY_TYPE_view() to create a custom field displayed in nodes that generates content dynamically via PHP. However, Drupal 9 seems to be ...
Anton's user avatar
  • 273
0 votes
0 answers
151 views

Update field without node save

I am a beginner in Drupal, I would like to insert a value into a node field. But instead of a node->save() I want to avoid any presave hook and insert it directly using sql query. I have the ...
el sparrow's user avatar
0 votes
0 answers
53 views

list_string field data disappears after making edits to node

I am maintaining a Drupal 9 site that I inherited. Unfortunately, if I attempt to edit any of the nodes, all the fields of type list_string are empty in the next revision. I did notice that the ...
nschildre's user avatar
-2 votes
3 answers
269 views

How do I show a block with a unique QR for each node? [closed]

There is requirement where I need to Place a Block on node where each block will be having the Unique QR code. I created an hard-coded QR code block with the following code. public function build() { ...
Akki's user avatar
  • 371
0 votes
1 answer
57 views

Can't save field translation

I have 2 languages on my site (English and Russian). I also have a content type "Home page" and some fields are translantable (configured in admin/config/regional/content-language) After ...
John's user avatar
  • 1
1 vote
1 answer
298 views

Get the node title field value in the form_state

Drupal version 9.3.9. This is a process of Ajax callback, where the value of the title field is required. In the form node add, the title is displayed. It seems that the form_state does not apply to ...
Belba's user avatar
  • 73