Skip to main content

Questions tagged [nodes]

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

Filter by
Sorted by
Tagged with
5 votes
3 answers
1k views

How to restrict access to a node via node/12 and allow access via a path like content/sometitle?

Problem: I want to restrict direct node access using node number www.example.com/node/12 and allow access using pathauto alias www.example.com/content/sometitle to anonymous user. This user should be ...
suneel's user avatar
  • 51
34 votes
5 answers
33k views

Node count for taxonomy terms

How can I display the node count values for taxonomy terms with sorting the result list in descending order of node count?
ya.teck's user avatar
  • 5,682
6 votes
4 answers
2k views

How to prevent a node being saved when using the Rules module?

Is it possible to prevent a node from being saved with Rules? This is what I do now: Create a rule Before saving content of type ''. Condition: IF ... TRUE => Redirect & set message Create a ...
nielsv's user avatar
  • 786
50 votes
12 answers
22k views

How do I hide nodes that shouldn't be directly accessed from users and search engines?

I've found that there are times I have a node that simply contains content that will be displayed somewhere else, but shouldn't be viewed directly. That is, no one should ever go to node/1234, but the ...
Chaulky's user avatar
  • 6,453
69 votes
6 answers
163k views

How do I get the current node ID?

In Drupal 7, if I wanted to get the node id of the currently displayed node (e.g. node/145) I could get it with the arg() function. In this case, arg(1) would return 145. How can I achieve the same ...
dbj44's user avatar
  • 4,764
6 votes
2 answers
5k views

How to use the Rules module to implement a custom redirect for an outdated URL?

I used to show content from a catalog via the Views module, accessing an external database, so that all of the URLs would be something like /content?name=[name]. For various reasons, I've opted to ...
astrosa's user avatar
  • 75
48 votes
7 answers
77k views

How can I programmatically create a node?

How can I programmatically create nodes with date and image fields? I know I can do it in Drupal 7 with the following code. global $user; $node = new stdClass(); $node->title = "YOUR ...
Yuseferi's user avatar
  • 22.2k
13 votes
5 answers
20k views

How do I programmatically update the allowed values of a list field?

I have created a field_time_zone field for the Article content type. I want to set the allowed values for that field to the values returned from system_time_zones(). For this, I implemented ...
Sugandh Khanna's user avatar
12 votes
5 answers
34k views

How to print paragraphs in twig template?

I have a content type, basic, where i have added a Paragraph field field_pr that has two fields: field_text, field_color. I have a twig template node--basic--full.html.twig where I want to print the ...
usernameabc's user avatar
  • 2,746
40 votes
9 answers
33k views

Count of nodes by type [closed]

I am looking for a snippet that lets me display the total count for a specific node type, e.g. "Pages = 167" or "Products = 10630." What code should I use to achieve this?
Diane's user avatar
  • 565
10 votes
2 answers
10k views

Override theme template from module without implementing a theme

I have a project on D8 where I don't use any custom themes, I use default seven theme for everything because there is no need of any visual theming. So My question: Is it possible to override theme ...
otarza's user avatar
  • 964
20 votes
4 answers
11k views

Relation vs. References vs. Entity Reference for managing node-reference-type relationships

References Entity Reference Relation It seems like there are several active modules that all have similar functionality. Can anyone offer any information as to which branch appears to be the most ...
starsinmypockets's user avatar
8 votes
3 answers
7k views

Show node IDs along with titles in Entity reference Autocomplete list

I'll like to add this functionality to the autocomplete widget in Entityreference field to show node ID next to the titles in the dropdown list. The reason behind the idea is to differentiate between ...
neemu's user avatar
  • 81
6 votes
5 answers
16k views

How to create a node with submissions of a webform?

I'm using Drupal 7 and created a content type 'NewArticle' with the fields 'Title', 'Text' and 'Image'. Users have the permission to create a 'NewArticle', but I don't like the way of displaying the ...
Jeroen's user avatar
  • 2,518
20 votes
4 answers
32k views

How do I add additional view modes for a node?

I am creating a custom content type. By default, nodes support only two view modes (full and teaser): function mymodule_view($node, $view_mode) { if ($view_mode == 'full') { $node->...
werqious's user avatar
  • 750
15 votes
14 answers
15k views

How to remove the "No front page content has been created yet." message from the front page?

I only want blocks on the homepage. Because I don't have any nodes, and I want to keep the homepage as /node I am getting a "No front page content has been created yet." message on my page. How do I ...
user12804's user avatar
  • 475
11 votes
5 answers
40k views

How to print fields in node.tpl.php?

I need to print individual fields from the $content variable in node.tpl.php file in separate div tags. How do I do that and how do I find out what the field's names are?
CobaltBabyBear's user avatar
41 votes
3 answers
55k views

How do I customize the search result page?

I have customized the teaser view of my content types and the page view. Now I need to use the teaser view for the search results page. By default, Drupal displays a full text jumbled mess for each ...
J-Fiz's user avatar
  • 1,353
20 votes
7 answers
15k views

fast saving single field value

I've got around 70k nodes of specified type on my site. I need to run an update on them. Some operations and setting one field to desired value. node_save is really slow and it causes crashes (too ...
Eloar's user avatar
  • 303
9 votes
1 answer
18k views

How can you render fields from an entity reference in node templates? [Drupal 8]

For context, I'm dealing with two content types: article and team_profile. In article nodes, we have an entity reference field pulling a team_profile node in to serve as the author information. I ...
alexbea's user avatar
  • 203
7 votes
3 answers
21k views

How do you theme a content type's create/edit form?

Like it says -- I've got a D7 content type whose editing form needs to be themed. I did this all the time in D6 by registering theme functions in template.php and writing the associated theming ...
Jim Miller's user avatar
  • 1,948
4 votes
2 answers
10k views

how to create rules to send email notification for node reference content?

I have two content types: job posting and job application. The job application content type has a node reference field for job posting. Whenever users create a job posting node, other users can send ...
Moorthy's user avatar
  • 585
3 votes
3 answers
8k views

How to create a node out of a webform submission?

I'd like to be able to create a node out of a webform submission in Drupal 8. It can happen either on successful submission or as an additional task after the webform has been submitted. I've seen ...
owenpm3's user avatar
  • 99
52 votes
9 answers
63k views

Where is the content of a node's body stored?

In the node table, you'll find everything except the actual body. Where can I find this body text? I'm assuming it's being stored as a blob somewhere.
rockstardev's user avatar
  • 1,049
41 votes
19 answers
48k views

How to delete all nodes of a given content type?

I have several thousand nodes of a particular content type. Using the web interface (example.com/admin/content), I can only delete about 50 at a time. How can I quickly delete them?
Greg's user avatar
  • 1,076
27 votes
7 answers
63k views

How to programmatically get the NID of the current node

I've pored over this old thread on drupal.org and it just kind of makes my head spin around. Pulling down the path and trying to parse out the NID from within it? There has to be a better way. And ...
beth's user avatar
  • 9,087
25 votes
5 answers
27k views

How can I get the node ID from a path alias?

I want to be able to get the nid but the only information I have is http://example.com/this-is-the-alias. Is there a way to get either the internal path of /node/* for that alias if I am not on the ...
BrandenB171's user avatar
  • 1,122
19 votes
5 answers
18k views

Get the list of all content types

How do I get a list of all the content types defined in a Drupal 8 site? In Drupal 7 it used to be node_type_get_types(), but it has been deprecated. I tried Entity::loadMultiple() but it doesn't ...
pbonnefoi's user avatar
  • 1,844
18 votes
5 answers
20k views

How I can delete all node/field revisions?

I have a drupal 7 sites, where it keeps node and field revisions. I keep revisions for the case where by mistake a new faulty version is saved and I want to revert back. But, now I want to clean and ...
john's user avatar
  • 1,601
17 votes
6 answers
7k views

View of users flagged by a user, users flagging a user, and nodes from users flagged by a user

I have a user flag that is pretty much like a "follow" or "subscribe" function. Basically I want to create 3 views for my website's user profile pages: A list of users flagged by a user (e.g. a ...
Jamie Chang Liu's user avatar
15 votes
6 answers
19k views

How to embed a view in a specific node?

I try to embed a view in a specific node. I found tutorials for doing this with Drupal 7 and PHP-Templates: <?php print views_embed_view('view_name'); ?> But I look for a way in Drupal 8 with ...
TiMESPLiNTER's user avatar
10 votes
4 answers
3k views

Is there a way to avoid anonymous user can see a node of a specific content type?

Is there a way to avoid anonymous users can see nodes of a content type, like a block or a view? I can control the access with a view, but if I know the link for a node, I can see it without first ...
Frank Giesecke's user avatar
6 votes
2 answers
3k views

Programmatically assign a node to an organic group

How can I programmatically assign a node to an organic group? I have tried the followings and non of them worked (assuming $target_group is the group ID that I want the $node to be assigned to): $...
Luca's user avatar
  • 479
6 votes
1 answer
11k views

How to disable the revision feature completely?

I've followed discussions here and on d.o about removing unneeded revisions tables. How would I completely prevent any data from being written to the node_revision and field_revision_* tables?
uwe's user avatar
  • 12k
5 votes
2 answers
14k views

Show all child nodes of a taxonomy term D7 [duplicate]

Ok, so I've been ripping my hair off for the past 2 days now. I'm developing a web-site with a car catalog which contains the following hierarchy (taxonomy hierarchy): -brand1 --model1 --model2 --...
zombar's user avatar
  • 71
4 votes
3 answers
10k views

How do I change the uploaded file name after the node has been saved?

How can I change the name of an uploaded file after the node has been saved? I know there is the FileField Paths module for this purpose, but it's still buggy for Drupal 7. I looked at the source of ...
Nick.h's user avatar
  • 710
3 votes
1 answer
910 views

How to properly manage field types for a content type created by a module?

I'm a bit confused about two different errors I get, which seem to contradict each other. I guess I didn't register my field types properly. The first one appears when I try to uninstall my module. ...
alex-schuster's user avatar
3 votes
4 answers
11k views

views and contextual filters with entity reference field

how do you use contextual filters to a views block when you want to use a reference field from the content type displaying the view? here's the simple scenario artist content type has some basic ...
Will's user avatar
  • 302
1 vote
1 answer
6k views

Field level permissions in Drupal 7

What is the best way to create a piece of content with multiple fields... allowing users to edit the content as a whole yet blocking the ability to edit. The setup I have is a piece of content that ...
WernerCD's user avatar
  • 784
1 vote
3 answers
2k views

How to bulk delete selected content/nodes?

I want to bulk delete data and along with it I need check-box where I should able to "select all" data to delete. I tried the Delete all module, which is helpful to delete all the content, but it's ...
kashish's user avatar
  • 307
40 votes
2 answers
33k views

How to get a node by its url alias?

I know I can load a node by its title with the node_load() function. Is it possible to load a node by its URL alias?
Moon's user avatar
  • 575
25 votes
6 answers
27k views

Programmatically attaching files

I have created the "Gallery" content type, and added two fields: "photo," and "document." I then used the following code for uploading a file in the "document" field: $file = file_save_upload('...
Vinodkumar SC's user avatar
14 votes
3 answers
9k views

How to delete a content type, programmatically?

I programmatically created a content type during a module installation (using field storage configuration). I want to delete that content type while uninstalling the module. Is there any way to do ...
Akash Jain's user avatar
13 votes
2 answers
19k views

How do I get a list of all taxonomy terms assigned to a node?

I have a node and want to get all the taxonomy terms assigned to the node. In drupal 6 I could use $node->taxonomy and the taxonomy_* functions but these don't exist in drupal 7.
Rwky's user avatar
  • 233
12 votes
7 answers
14k views

Display comma-separated list of taxonomy terms?

In my node.tpl.php template, I want to print out a list of taxonomy terms (the taxonomy is called "channels."). If I use: <?php print render($content['field_channel']); ?> It works, ...
Mike's user avatar
  • 755
11 votes
7 answers
20k views

How to hide page title based on node type using template_preprocess_page()

I am trying to hide the title of the current page (as printed by page.tpl.php) if the current page is 1) a node in full display (as opposed to teaser mode), AND 2) the node type is either concert or ...
diekunstderfuge's user avatar
9 votes
2 answers
1k views

"changed by" on nodes

mysql> select nid, uid, created, changed from node; +-----+-----+------------+------------+ | nid | uid | created | changed | +-----+-----+------------+------------+ | 1 | 8 | 1336040166 |...
cherouvim's user avatar
  • 1,937
9 votes
2 answers
6k views

Remove the 'read more' and 'Add new comment' links on the home page

How do you remove or modify the list of links shown after the content?
Onita's user avatar
  • 714
8 votes
4 answers
2k views

Finding all nodes not referenced by a menu entry or another node

In the course of creating the content for a site, we've ended up with orphaned content nodes that are not linked to from anywhere. I'd like to find and examine these. Surprisingly, I can't find a ...
Dan Halbert's user avatar
  • 1,009
8 votes
2 answers
13k views

How do programmatically create fields for content types, and ADD them to the the content type form

Say I have this field, "map_description". I know I would this function to define the field: $field = array( 'field_name' => 'map_description', 'cardinality' => 1, 'type' => 'text', ); ...
rugbert's user avatar
  • 249

1
2 3 4 5
14