Questions tagged as ['nodes']

The most basic form of content on a Drupal site is a node.
Score: 1
Setting latest revision has been delayed
ar flag

We are (still) using Drupal 8, the latest version, as a CMS for content editing. Our platform is huge and it has 100+ editors who are constantly adding/editing content, and also 20 importers which are importing content all the time.

We are hosting our platform on Azure Kubernetes Service, and using custom Azure VM where we host our custom MySQL server. We have had this setup for a year and a half ...

Score: 0
mathieu avatar
How to limit the addition of a single node in a Group?
mw flag

On my Drupal 9 site and Group module. I created a type of group "Blog". I want that in a group, only one node of type "Article" can be added.

How to limit the addition of a single node in a Group?

So a maximum "Article" type node per group.

Score: 1
Make Title field "not required" or workaround how to prefill and hide it (drupal 9.2.8)
ug flag

On my site (drupal 9.2.8) users add content and there is no need to put any information to 'Title' field. I was trying to make this field not required via form_alter in custom module but it did not work:

function yourmodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
  if ($form['#form_id'] == 'node_somenode_form' or $form['#form_id'] == 'node_somenode_form') ...
Score: 0
Provide menu link when creating node programmatically and append it to parent menu link
in flag

I am creating a Node programatically:

  'title' => "Some name",
  'type' => "people",
  'body' => $params['body'],
  'field_people_degree' => $params['field_people_degree'],
  'field_people_email' => $params['field_people_email'],
  'field_field_image' => ['target_id' => $this->createImageFile($params['field_field_image'], $params['field_pub_tool_id'])->id()],
  ' ...
Score: 0
SomebodySysop avatar
create views filter from sql
gb flag

I've been trying to create a view that gets all nodes that are in moderated "draft" state as created by the group content moderation module. The current views content state filter will not work. The module has a patch, but this patch requires giving a user site-wide content revision permissions, and we only want to give those permissions on the group level.

I wish to create my own views filter f ...

Score: 0
The "node" parameter was not converted for the path "/node/{node}"
tr flag

I have the following error in the filters with parameters in view type pages. will there be any solution to this problem?

Drupal\Core\ParamConverter\ParamNotConvertedException: The "node" parameter was not converted for the path "/node/{node}" (route name: "entity.node.canonical") in Drupal\Core\ParamConverter\ParamConverterManager->convert() (line 104 of /var/www/html/web/core/lib/Drupal/Core/P ...
Score: 0
pazitos10 avatar
SQL Error when trying to remove content type field
np flag

I was trying to create a new Content Type for my site and I chose a field name ("description") that already used for other content types.

The problem occurred when saving changes as the machine name for the field already exists for the fields in other Content Types but with a different field type. In other Content types I used the default "Long Text" field type but in this case I chose "Read More ...

Score: 0
mt.i.1 avatar
Adding custom field generated by drush to available fields on node
us flag

I have an existing custom module on my D9 website and I need to make some changes inside it. I want to add a field (boolean) into any content type page edit without doing it manually.

So I need my field to be available here /admin/structure/types/manage/mycontenttype/fields/add-field

On my CLI, i've run this command drush generate field, which gave me those files :

  modules/custom/mymdule/config/ ...
Score: -1
How do I access the protected value of node entity?
in flag

I have a view node and I use the below code to Kint out the node objects:

$node = \Drupal::entityTypeManager()

returns the below output:

enter image description here

I get to see the properties of each node. In this, I want to access the target_id/value of the highlighted field - field_cp_level2_ref_level3. I tried the below line and it is coming out as null:

Score: 0
Jean da Silva avatar
Is there a way to customize a ListBuilder for a specific node content type?
cn flag

I'm having trouble with listing nodes and content types. There are many different content types in my drupal site, and all of them are listed inside "contents" page (/admin/content). I can filter then by type, but it would be much better for every content type to have its own listing page.

The only way I've done admin listing pages in the past was with custom entities using EntityListBuilder. The ...

Score: 0
Asatur Vardanyan avatar
Restrict access to specific node by role
jp flag

I am working on a Drupal 9 project. I need to restrict access to the node with id 1083 for "delegate" user role. For this I have used hook_node_access_records() and hook_node_grants():

 * Implements hook_node_access_records().
function wtotfaf_user_node_access_records(NodeInterface $node) {
  $grants = [];
  if ($node->id() == 1083) {
    $grants[] = [
      'realm' => 'delegate_view_acti ...
Score: 0
Is there a way to synchronize a webpage from another website into Drupal?
es flag

A restaurant has its menu database in Foodpanda.

The owner wants that menu to appear in the website.

  • We can manually duplicate all menu courses from FoodPanda to Drupal, upload the same images, etc. each menu course as a standalone node of a menu content type and then add some module for purchasing courses from the website (as delivery).
  • We might also be able to move the database from FoodPanda to a  ...
Score: 0
mxr10 avatar
How do I programmatically set a content reference by name for a node?
id flag

Hi team i have some isssues.

I'm creating a node and i would like to set a content reference by name not by id, i'm doing this but this is not working: 'field_content_type_items' is referenced to another content type

$node = \Drupal\node\Entity\Node::create([
    'type' => 'items',
    'status' => $status,
    'title' => $title,
    'field_content_type_items' =>  "CUN",

Also i tried with  ...

Score: 1
Lambic avatar
How to import a custom content type in phpunit
ph flag

I'm trying to write some PHPUnit Kernel tests that use a custom content type which seem to work until I try to reference fields on the content type. I'm guessing the content type isn't being imported from config. Is there a correct way to do this?

Example code which works in drush php but does not work in phpunit:

  public function createAction() {
    $storage = $this->container->get('entity_ty ...
Score: 4
sailormoon avatar
How to prevent a node from being deleted while performing a delete operation?
cn flag

I want to prevent a node from being deleted while a delete operation is performed on it. For example in administration panel if user clicks "Delete" on the node, the node shouldn't be deleted if he is not an administrator. Permissions and user roles are not a problem for me, the problem is "stopping" delete operation.

I found hook_entity_predelete(), which is perfect, it runs exactly just before deletin ...

Score: 0
drupalhorn avatar
Auto create a feed when a node is added
ro flag

I am looking for a way to automatically add a feed (of a specific feed type), whenever a node is added (for a specific content type) using the node fields to auto-create the feed.

I have searched this site and globally; the closest solution I could find is the one described in Programmatically create and trigger feeds importer, for Drupal 7, although I cannot see why a template should be needed.


Score: 0
Using Tac Lite in combination with Paragraphs
ma flag

For our new Drupal 9 (or 8 if necc.) website we require a very fine controllable access structure where we can give and restrict access on a user by user basis. Not only for a content type but also for the paragraphs (or more atomic components of a page). With Tac Lite we can already set the permission via taxonomy terms on a user bases to view a node. But now we would like to also controll single parag ...

Score: 0
jfc avatar
Is there a way to render the title of every node from a single content type?
us flag

I have a page on a Drupal 9 site that will have a filter and a search bar. The filter needs to have each product and each region the product is sold in.

So I created 2 content types - Product and Region, and created a node for each one that just has a title.

I want to loop through each Product and Region node and display them on the page that has the filter.

Is it possible to render this data in a TWIG ...

Score: -1
jfc avatar
How do I suggest to use a template name like "node--[content-type-name]"?
us flag

I would like to name my node template after the content type title, but my suggestions only show the node number.


  • html--node--1.html.twig
  • html--node--%.html.twig
  • html--node.html.twig
  • x html.html.twig

I don't want to name it node--1 just in case the node ID changes in the future. I'd like to name it node--content-type-name.

Is there a setting to enable this?

Score: 0
ashique avatar
How to inject/append child element to a radios element and give it an AJAX callback?
cn flag

How can I add independent child element to a radios element in a form? The radio elements are created by the following code.

$form['orderinfo']['billshipaddresses']['billingaddresses'] = [
  '#type' => 'radios',
  '#title' => 'Billing Address',
  '#options' => $formaddressesOptions,
  '#default_value' => '',
  '#ajax' => [
    'callback' => '::buildShipBillAddresses',
    'wrapper'  ...
Score: -4
Shyam Jha avatar
The website encountered an unexpected error. Please try again later. as shown in body
uz flag

I tried to set up my drupal 8 full project on localhost but after set up when I run project getting error as shown below:-

The website encountered an unexpected error. Please try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 150 of core\lib\Drupal\Core\Entity\EntityTypeM ...

Score: -1
John avatar
Show two content types in same view
rs flag

Drupal 8 newb here,

I have two basic types I need to show in my front page: There’s a “Restaurants” content type and a “Chefs” content type.

These are shown in my site like this:

Site layout

The types are unrelated, I just need to show them in the same page as featured.

I’ve found documentation on how to make blocks and views but nothing about mixed content, which seems to me like a common use case.

Score: 0
julianx2rl avatar
How can I use the time.html.twig template for the node "created" field?
cn flag

When a view shows a date from a newly created field, it uses the time.html.twig template. When it shows the node created field, it just prints a string surrounded by <span> tags.

I'm guessing I just have to somehow specify that the created field must be rendered using the time.html.twig template, but I don't know how to achieve this.

How can I set a view to render the created field using the t ...

Score: 0
J.g avatar
Getting the version history of a node
us flag

Is there a way to get the versions history of a node using REST or JSON API? I would like to be able to view all version IDs of a node in JSON format.

Score: 0
abe-cedarian avatar
Within a node template how can I tell what regions are in use/ occupied?
kr flag

I am trying to create a preprocess function in my .theme file in order to make a variable available to node templates.

I want the variable to contain just the names of all regions that are currently in use (i.e. rendering content).

The idea being, if I have a region called left_hand_nav which is rendered on some (not all) pages, and I have a node called generic_page, from my generic_page node templa ...

Score: 1
Custom display in saved Entity reference in Widget field
us flag

We have an entity reference field widget. Based on a view where you can enter the code of a product to get to the product reference.

The widget shows the 2 fields (code) - (Title) when we type in the widget.

But after saving, only the title and the Node ID is shown. Title (nodeID)

How can I override what is displayed in the entity reference field to include my product CODE in prefix? (code) - (Title) ( ...

Score: 1
shelane avatar
Creating default content on site install with related entities
cn flag

We use the Default Content module to install default content on each new site of our multi-site Drupal platform. Version 2 changed to only use UUID of the content you are exporting (done from the local development environment to generate content). However, some of our default content are items like vocabulary terms which are then related to the node. But this is no longer exporting the ID, so the ID  ...

Score: 2
Missing bundle for entity type node after upgrading
ph flag

I recently upgraded a local sandbox to Drupal core 9.2.4. While testing things out, I got an error when trying to add a new article content from /node/add/article.

The log shows the following message.

Drupal\Core\Entity\EntityStorageException: Missing bundle for entity type node in Drupal\Core\Entity\ContentEntityStorageBase->doCreate() (line 97 of /var/www/drupal9sandbox/docroot/core/lib/Drup ...

Score: 0
Sam Ng avatar
Custom Migration Plugin MySQL Error
ck flag

I've run into the following error when running the command drush migrate-import custom_spotlight where custom_spotlight is the name of the plugin. I've been following along with this guide: but I'm not exactly sure what went wrong here. It seems when the placeholder :nid is substituted with a value, there are quotes inserte ...