Drupal Cheat Sheet - Accessing Node fields programatically

Note Statistics

Note Statistics

  • Viewed 32 times
Sat, 07/24/2021 - 18:30

Accessing properties

The convention below can be used to access all node properties.

 // or 

// a custom text field
// reference field
// a file field

Now there are wrapper methods in node that you can use.

Get Node's ID

$node->id();  // 1234

Get node's bundle/type

$node->bundle();    // 'article'

Get node's title


Check if the node is promoted


Check if the node is sticky


Authored by