Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Here is an overview of the node object broken down into Drupal 7, Drupal 6 and Drupal 5.
7.x - $node - Node object
$node->nid | Node ID. |
$node->vid | The revision ID of the current version of this node. |
$node->type | Type of node (e.g. book, page, forum), which is also the entity bundle. |
$node->language | The default language for this node. |
$node->title | Page (or, more accurately, node) title. |
$node->uid | User ID of node creator. |
$node->status | unpublished/published (NODE_NOT_PUBLISHED | NODE_PUBLISHED). |
$node->created | UNIX timestamp of node creation date. |
$node->changed | UNIX timestamp of last time node was changed. |
$node->comment | Whether comments are allowed on this node (COMMENT_NODE_HIDDEN | COMMENT_NODE_CLOSED | COMMENT_NODE_OPEN) |
$node->promote | Promoted to front page (NODE_NOT_PROMOTED | NODE_PROMOTED). |
$node->sticky | Sticky (NODE_NOT_STICKY | NODE_STICKY). |
$node->tnid | The node ID of the translation source (or parent, if node is a translation). |
$node->translate | Does the translation need to be updated (0|1)? |
$node->revision_uid | The user ID of the user who created the current revision. |
$node->body | Array. Body content of node. Long text field with summary. Note: Don't assume that this field will exist, as it is possible to remove it via Manage Fields on each content type. Similarly, modules that define a custom node content type may not even attach a body in the first place. |
$node->log | Message left by the creator of this revision, explaining the changes. |
$node->revision_timestamp | Unix timestamp showing when current revision was created. |
$node->name | Username of node creator. |
$node->picture | User avatar of the node creator. |
$node->cid | CID of last comment? |
$node->last_comment_timestamp | Timestamp of last comment (Unix Epoch C). |
$node->last_comment_name | Name of last comment author |
$node->last_comment_uid | UID of last comment author. |
$node->comment_count | Number of comments made on node. |
$node->data | Serialized string of data associated with the node. |
$node->rdf_mapping | W3C standard to describe structured data. See http://api.drupal.org/api/drupal/modules!rdf!rdf.module/group/rdf/7 |
6.x - $node - Node object
$node->nid | Node ID. |
$node->type | Type of node (e.g. book, page, forum). |
$node->language | The default language for this node. |
$node->uid | User ID of node creator. |
$node->status | unpublished/published (0|1). |
$node->created | UNIX timestamp of node creation date. |
$node->changed | UNIX timestamp of last time node was changed. |
$node->comment | Whether comments are allowed on this node: 0 = no, 1 = read only, 2 = read/write. |
$node->promote | Promoted to front page (0|1). |
$node->sticky | Sticky (0|1). |
$node->tnid | The node ID of the translation source (or parent, if node is a translation). |
$node->translate | Is a translation (0|1). |
$node->vid | The revision ID of the current version of this node. |
$node->revision_uid | The user ID of the user who created the current revision. |
$node->title | Page (or, more accurately, node) title. |
$node->body | Body content of node. |
$node->teaser | Teaser (the initial part of the body). |
$node->log | Message left by the creator of this revision, explaining the changes. |
$node->revision_timestamp | Unix timestamp showing when current revision was created. |
$node->format | which filter applies to this content. |
$node->name | Username of node creator. |
$node->picture | User avatar of the node creator. |
$node->date | Long date, including timezone data, of when the node was created. |
$node->revision | TRUE/FALSE this is a new revision (if TRUE, will be saved as a separate entry in the database). |
$node->menu | Array containing the menu item assigned to the node. |
5.x - $node - Node object
$node->nid | Node ID. |
$node->type | Type of node (e.g. book, page, forum). |
$node->language | The default language for this node. |
$node->uid | User ID of node creator. |
$node->status | unpublished/published (0|1). |
$node->created | UNIX timestamp of node creation date. |
$node->changed | UNIX timestamp of last time node was changed. |
$node->comment | whether comments can be added, read, or accessed, for this node. |
$node->promote | Promoted to front page (0|1). |
$node->moderate | Moderation enabled (0|1). |
$node->sticky | Sticky (0|1). |
$node->tnid | The node ID of the translation source (or parent, if node is a translation). |
$node->translate | Is a translation (0|1). |
$node->vid | The revision ID of the current version of this node. |
$node->revision_uid | The user ID of the user who created the current revision. |
$node->title | Page (or, more accurately, node) title. |
$node->body | Body content of node. |
$node->teaser | Teaser (the initial part of the body). |
$node->log | Message left by the creator of this revision, explaining the changes. |
$node->revision_timestamp | Unix timestamp showing when current revision was created. |
$node->format | which filter applies to this content. |
$node->name | Username of node creator. |
$node->picture | User avatar of the node creator. |
$node->date | Long date, including timezone data, of when the node was created. |
$node->revision | TRUE/FALSE this is a new revision (if TRUE, will be saved as a separate entry in the database). |
$node->menu | Array containing the menu item assigned to the node. |
Comments
$file object
Edit: thought getting this info would be simple, but as PHP is very dynamic with objects.. well anyways.
$file objects generated by file_scan_directory() look like this:
file_check_upload() also creates these fields:
do does even reach anywhere outside the function? Is there a better way to dump this information?
See API book
See API book
Some more snippets - Drupal 6 taxonomy and CCK fields
$node->taxonomy
is an array of taxonomy objects, as returned bytaxonomy_get_term
. Here's an example term:Each CCK field you add in the admin interface is represented on a node by a new attribute, invariably beginning "field_" e.g.
$node->field_venue
or$node->field_subtitle
. These are numbered arrays, even if the field is single valued (it's a single-value array). Each CCK field array element is itself an array, with field names which typically match the columns in the database where the CCK data is stored.--
J-P Stacey, software gardener, Magnetic Phield
Path for the node
For the node path, if you have the path and pathauto module installed, you get a $node->path var.
This is the alias-ed path for you to check!
Nothing unreal exists.
Is True for D7?
Is this still true for Drupal 7? I couldn't get this property in D7.
Not sure
But this works:
drupal_lookup_path('alias',"node/".$node->nid);
And I can't imagine why that function would exist if you could just call it in the object.
Thank You
Saw that this is how it's done now. Thank you for the reply.
Thank you for posting this.
Thank you for posting this. Most handy page ever.
Passing the Language to Taxonomy for use on Faceted Search.
I had a problem: How to show the count (total) of Nodes on Faceted Search Guided Search.
Solution: Computed CCK field.
Approach:
1 - Created my Computed field and passed the:
$node->language;
$node_field[0]['value'] = $node->language;
I hope this help somebody with the same problem in the future =D
enjoy
Could we have these objects
Could we have these objects documented in api.drupal.org?
For example I am looking for a user object documentation, but cannot find any.
My Drupal sites:
There is another request for
There is another request for this at #681768: Documentation on $node object is missing
Yea this would be great
Yea this would be great
What about null objects?
What about null objects?
great post,i got it working
great post,i got it working afer some hours now
munka állás
Beware of $node->date property
If for any reason you want to hide 'Authored On' textfield from the node form, do not use
as this will remove the field from the form (obviously) and will make 'created' node property update together with 'changed' on each node save.
This behaviour comes from node_submit() line:
So, instead use the following code to hide the 'Authored On' field:
Software Engineer | DrevOps| www.drevops.com