Questions tagged [nodes]
The most basic form of content on a Drupal site is a node.
7,538
questions
0
votes
0
answers
22
views
Can't save node when fields are altered with entity_bundle_field_info
I have a node called Program, with a large number of fields and a custom node form. Because of the very complex way we're indexing it for search, I have two fields, award_type and award_goal, which ...
0
votes
0
answers
57
views
Title length error
We just started receiving the following error when attempting to add a new content item: "Title cannot be longer than 70 characters but is currently 79 characters long." This happens ...
0
votes
1
answer
13
views
Promotion options not visible to Editor role
I have a "Editor" Role with limited access rights. It can basically only create blog type nodes.
I'd like to expose to them the possibility to make to publish the node to the frontpage via ...
0
votes
0
answers
54
views
View breaks the page output
Has anyone encountered this problem or can at least help me debug it?
The views is displayed as standard if the parameters are specified.
Format:Unformatted list | Settings
Show:Field
If I change it ...
0
votes
1
answer
25
views
How do I sort view results by query order?
In my twig I use {{ drupal_view('slider', 'block_1', '74,84,82' ) }}, how can I make sure the output of this view has the slides in that specific order?
Currently on D9. I've looked around but can't ...
0
votes
0
answers
35
views
Deny access to pages or nodes base from a database table
I was modifying a 2fa module for restricting users to access other account's page (user/%/2fa) which is working.
function custom_2fa_menu() {
$items['user/%/2fa'] = [
'title' => t('...
0
votes
1
answer
85
views
How to have a different hero image per node?
What we want: Users should be able to choose an image, add call to action links, and a few other options when setting up a hero for the specific page they are creating. We have three different content ...
0
votes
0
answers
45
views
How can I programmatically get the node title? [duplicate]
A drupal newbie here. I'm looking to build an "issues navigator", a custom block displaying a menu. I'd like to set the "current issue" automatically, from the title of the node ...
1
vote
0
answers
10
views
How can I add the hero section image in the View to REST_API?
Hello im using Drupal 9.5.9 version. How can I add the hero section image in the View to REST_API?
I have created an api with Rest_API to fetch data from Views I have created. I have no problem ...
2
votes
1
answer
69
views
Is it logical to give a homepage an alias? [closed]
Drupal allows us to give a URL alias to any node (example.com/my-alias). The "Home page" node is not an exception.
Is it logical to give a homepage an alias?
Shouldn't we just keep it "/...
-3
votes
2
answers
91
views
How can I embed PHP code in HTML?
I want to execute few curl commands from my Drupal site using PHP.
Idea is to create a custom content type that accepts php code. I understood from the internet I have to create a file "node--...
0
votes
0
answers
20
views
MSSQL - How to get a list of documents from a node that is using a space and a view?
I have a list of documents that are associated with a node of type space. The space has a page with a view and filter to list documents only related to that node.
I'm trying to query the database to ...
0
votes
0
answers
14
views
How to filter webform nodes with a contextual filter that restricts webforms to those which have not been answered
I have a webform node display page that shows webform nodes that are available to individual users. Individual user accounts have a field called Project which has a Project name. This allows users to ...
0
votes
0
answers
52
views
How can I search for existing nodes with "Text format" = "undefined"?
I've upgraded to Drupal 10 from an earlier release, which used the PHP module (not yet available for Drupal 10). Therefore, I had to uninstall the PHP module before upgrading, leaving the "Text ...
0
votes
0
answers
35
views
Inline Entity Form - is it possible to add field from child entity's taxonomy reference field
I have the below structure on my Drupal 9 site:
Product content type
-- field_product_integration (references contents of type Integration)
Integration content type
-- field_product_feature (...
0
votes
0
answers
43
views
Populate field value based on external API response
My custom Drupal 10 module takes the value of an address field submitted by the user during node creation, sends that to an external API, and then fills a taxonomy term reference field based on the ...
1
vote
1
answer
104
views
How can I copy a field to another field?
I have an Article content type for which I want to change the machine name of its fields. I created new fields with a different machine name.
How do I copy the old fields to the new fields?
1
vote
1
answer
41
views
How to access the node/term field-values in a cleaner way?
My code is filled with methods like these to access field values:
\Drupal::entityTypeManager()->getStorage('node')->get('field_name')->getValue()[0]['value'];
\Drupal\taxonomy\Entity\Term::...
2
votes
1
answer
934
views
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist
I have upgraded drupal 9 to drupal 10 and now while creating a content page or editing the existing content page it is throwing error in error logs
Drupal\Component\Plugin\Exception\...
0
votes
1
answer
119
views
How can I programmatically save node components?
There is a site with number of nodes including layout canvas and site studio components available in a node.
When there will be changes in one of the components (new field added with default value), ...
-2
votes
1
answer
32
views
Is there a way to allow entering a value in a node's field if inserting a new node, but make the field disabled if updating that same node?
I'm using Drupal 7 and I have a standard text field in my Content Type. If the user with role "Standard User" is adding a new node then they should be able to set the Status field text value....
1
vote
0
answers
27
views
How to give ability to create custom NID numbers via API REST post when creating content?
I'm using Drupal 9.4 and I tried to pass in a nid value in my POST via the Drupal api. I'm getting the error:
Response: {"message":"Access denied on creating field \u0027nid\u0027."...
0
votes
0
answers
61
views
Is it possible to not show extra box by default when Allowed number of values is Unlimited in Text (formatted, long, with summary)?
I have created a long text formatted field with unlimited allowed number of values. But it is giving one extra box as default.
Every time user edits the content the empty box will show. That is so ...
0
votes
0
answers
20
views
Is it ok to share a comment field with multiple content types?
Imagine I want to convert individual forum threads (topic + comments) into a content type 'Blog post' to preserve them for the long term.
In order to make this work, the comment field of 'Blog post' ...
0
votes
1
answer
61
views
How can I overwrite the value of a field in a bundle class?
In Drupal 9 I would like to know if it is possible to overwrite the value of a field in a BundleClass. Looking at the Drupal API, I see that it is common to use either hook_entity_view_alter or ...
0
votes
2
answers
82
views
How do I programmatically assign a new book when a new node is created?
For a given content type, if a new node is created and no book is assigned, I'd like to create a new book and assign the new node to that book.
(some background - that content type is the book cover, ...
-1
votes
1
answer
87
views
Getting old node field value in update hook
Hi I'm using the node update hook in my custom .module file in my Drupal 9 site. I have a field called field_amount. And I was wondering if I can access the old value of that field within my update ...
0
votes
1
answer
142
views
Prevent last updated property from changing when updating node in code?
I have this code that updates a node in a queue worker:
$changed = $entity->getChangedTime();
// Don't update the changed time by
$entity->setChangedTime($changed);
$...
2
votes
3
answers
151
views
Append new paragraph item to existing node
I want to append a new paragraph item to a existing node, which has previously a paragraph item. I just want to add another paragraph item with the previous one. But my script only updates the ...
0
votes
1
answer
86
views
How to make it so theme function isn't used when editing a node with layout builder
I have the following two functions in my .theme file that I'm using to gleam various bits of information from both the path alias and internal URL of the page being viewed. They are:
function ...
0
votes
1
answer
26
views
Unable to update node entity fields using custom form
There is a certain content type, in which there is a field to enter a node or taxonomy.
I want to create a new node for that content type using a custom form and register the node or taxonomy in the ...
1
vote
1
answer
232
views
How can I set view permissions for content type to make it visible to autenticated users only?
I want a content type to be only visible to authenticated users.
Now the edit permission dialog only offers permissions for modification, not for displaying the published content.
Until Drupal 9, I've ...
0
votes
1
answer
125
views
Creating a Custom Content Listing Page based on specific content type or taxonomy terms selected in the node
I am trying to create a content type that generates a list of content/nodes based on other content type or taxonomy terms selected within that node in the content type. I have a general content type ...
1
vote
2
answers
128
views
When adding new nodes how can I pre-populate the body field with the body of another node?
I have a Drupal 9 website with number of nodes that I use as templates, I clone them to create nodes with the same body text.
However, I want to make this process simpler by prepopulating the body ...
0
votes
1
answer
273
views
Field values in node HTML body
I am using Drupal 10 and trying to edit the body of a node. I want to use the node field values in the HTML body, for example [field_name], but this does not appear to work as it only shows that ...
0
votes
1
answer
152
views
Use AJAX On Node Add Form To Change Field Required Status
On a node/add form I have a pair of fields that need to be able to control one another. The first field allows a user to enter a birthdate, the second field allows the user to say the birthdate is ...
0
votes
0
answers
59
views
How to modify the "href" attribute of some of the links of an html field type?
I'm using drupal 9.4.8 and I have a content type called "articles" which has a "body" field (which is a reference to a paragraph) and I'm making an algorithm to check all the ...
0
votes
1
answer
77
views
Statistics counter based on user role
I need to track some basic usage statistics for a subset of my authenticated user roles in Drupal 9.
Is there a way to make the core statistics counter only count node views based on user roles? The ...
-1
votes
1
answer
79
views
How to remove author field from the 'advanced' field group on the node edit form
I've got several node edit forms that, in most themes, display the 'advanced' group in a sidebar. I have other plans for the sidebar, though, so I don't want that behavior.
I edited some twig and css ...
0
votes
0
answers
14
views
eCommerce Products Permissions per Node
Good day
We are building an eCommerce Platform where multiple users can be able to register, login, create, edit and delete their Profiles and Products.
The main feature is to have each user to only ...
0
votes
0
answers
35
views
Headless and custom node / entity access
I struggle to set up custom access rules for "nodes" that are viewed via the
jsonApi
entityQueries which response via json endpoint
What I try to achieve:
I need to skip a node, that ...
0
votes
1
answer
114
views
Run custom php code or file in drupal content type form submission
I have this drupal site, there is a candidate registration page where anyone can fill the details (name, gender, address, mobile no etc) and submits and a success node page is displayed with all ...
0
votes
0
answers
20
views
Taxonomy field not displaying in a Node built with Paragraphs
I have a node type called Profile.
It includes a paragraph type called Person. The fields in that paragraph type are:
Name (text)
City (taxonomy field)
Brief (text).
Whenever I look at a published ...
0
votes
2
answers
207
views
How show field labels in the node display even if it's empty
While showing a node, only the filled fields are rendered.
I wanted to be able to show the empty field labels, and I was looking for something like the ability to uncheck an option such as 'Hide if ...
1
vote
0
answers
27
views
How can I find all the nodes that use a hierarchical vocabulary taxonomy term and reference a child term but not its parent term
I am using Drupal 7.
I have a content type "Public Resource" that uses a hierarchical vocabulary called "Resource Topics" that has up to 3 levels (parent->child->child of ...
0
votes
0
answers
23
views
How to access block contents in run within hook_form_alter? [duplicate]
I am using Drupal 9 and I need to get the block content within hook_form_alter implementation, I tried these lines:
$bid = 'consumerorganizationselection';
$block = \Drupal::entityTypeManager()->...
1
vote
0
answers
59
views
Node edit form - Is it possible to load entity reference field data on click after the form has finished loading?
I have a custom node type (let's call it Project) with many fields. Three of these fields are of an Entity reference type, referencing other related nodes (let's call them Project Attachments A, B, ...
1
vote
2
answers
593
views
How can I get a rendered node field value with filters applied?
I'm trying to use a REST resource that accepts a node title and returns a JSON interpretation of a single field. This requires raw HTML that I can then use in DOMDocument. To get the rendered value of ...
0
votes
1
answer
87
views
Unable to add custom css from asset injector module to content type
I have a content type called Advertisement on my Drupal site. I want to add some custom css functionality to this content type (as in, when I create an advertisement from the "Add Content" ...
0
votes
1
answer
61
views
Empty node references on node creation and on node load
I never noticed it, but:
If I create a node containing a reference and set the reference field to null, the field is still set as an EntityReferenceFieldItemList, e.g. the following code
echo "...