Questions tagged as ['nodes']

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 ...
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.

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') ...

I am creating a Node
programatically:
Node::create([
'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()],
' ...
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 ...

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 ...
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 ...
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/ ...

I have a view node and I use the below code to Kint out the node objects:
$node = \Drupal::entityTypeManager()
->getStorage('node')
->loadMultiple();
dpm($node);
returns the below output:
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:
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 ...
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 ...

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 ...
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 ...
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 ...
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 ...
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.
...

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 ...
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 ...
I would like to name my node template after the content type title, but my suggestions only show the node number.
FILE NAME SUGGESTIONS:
- 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?
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' ...
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 ...
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:
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.
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 ...
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.
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 ...

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) ( ...
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 ...

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 ...
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: https://www.metaltoad.com/blog/drupal-8-migrations-part-4-migrating-nodes-drupal-7 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 ...