Drupal: $node object description
In this article, we will study $node object which is available in node.tpl.php template to use it for adjusting of a node design.
Solution:
You can view content of a node with standard PHP functions (insert the following code to node.tpl.php): print_r($node)
Variables of $node are:
- body – document text
- changed – a date of a change in Unix-format
- comment – if comments are enabled. There are three values for this variable
- comment_count – number of comments.
- created – creation date in Unix-format (string(10) “1198024338”)
- data – was NULL
- files – attached files
- format – input format number starting from 1.
- last_comment_name – name of the last commenter
- last_comment_timestamp – date of the last comment in Unix format
- moderate – moderation flag. Equals to 0 if a node doesn’t require moderation.
- name – name of an author
- nid – id of a node
- path – relative path synonym (“content/turpis-premo-inhibeo-abico-luctus”)
- picture – user picture (chup)
- promote – “on home”=1, otherwise=0
- revision_timestamp – revision date in Unix-format
- status – published= 1, otherwise=0
- sticky – above the others =1, otherwise=0
- taxonomy – parent of a node. This is an array.
- teaser – teaser
- title – node title
- type – node type
- uid – id of an author
- vid – version id of a node. Doesn’t always equals to nid.
Additional modules
Additional modules could add their own variables to this object. These modules are:
- CCK – every field you add will be a set of parameters
- Nodeteaser – adds $node->nodeteaser, which is TRUE or FALSE; the proper teaser is in $node->teaser.