1. 4.7.x themes/pushbutton/node.tpl.php
  2. 4.7.x themes/bluemarine/node.tpl.php
  3. 4.7.x themes/engines/phptemplate/node.tpl.php
  4. 5.x themes/engines/phptemplate/node.tpl.php
  5. 5.x themes/bluemarine/node.tpl.php
  6. 5.x themes/garland/node.tpl.php
  7. 5.x themes/pushbutton/node.tpl.php
  8. 6.x modules/node/node.tpl.php
  9. 6.x themes/bluemarine/node.tpl.php
  10. 6.x themes/pushbutton/node.tpl.php
  11. 6.x themes/garland/node.tpl.php
  12. 7.x themes/bartik/templates/node.tpl.php
  13. 7.x themes/garland/node.tpl.php
  14. 7.x modules/node/node.tpl.php

node.tpl.php

Theme implementation to display a node.

Available variables:

  • $title: the (sanitized) title of the node.
  • $content: Node body or teaser depending on $teaser flag.
  • $picture: The authors picture of the node output from theme_user_picture().
  • $date: Formatted creation date (use $created to reformat with format_date()).
  • $links: Themed links like "Read more", "Add new comment", etc. output from theme_links().
  • $name: Themed username of node author output from theme_username().
  • $node_url: Direct URL of the current node.
  • $terms: the themed list of taxonomy term links output from theme_links().
  • $submitted: themed submission information output from theme_node_submitted().

Other variables:

  • $node: Full node object. Contains data that may not be safe.
  • $type: Node type, i.e. story, page, blog, etc.
  • $comment_count: Number of comments attached to the node.
  • $uid: User ID of the node author.
  • $created: Time the node was published formatted in Unix timestamp.
  • $zebra: Outputs either "even" or "odd". Useful for zebra striping in teaser listings.
  • $id: Position of the node. Increments each time it's output.

Node status variables:

  • $teaser: Flag for the teaser state.
  • $page: Flag for the full page state.
  • $promote: Flag for front page promotion state.
  • $sticky: Flags for sticky post setting.
  • $status: Flag for published status.
  • $comment: State of comment settings for the node.
  • $readmore: Flags true if the teaser content of the node cannot hold the main body content.
  • $is_front: Flags true when presented in the front page.
  • $logged_in: Flags true when the current user is a logged-in member.
  • $is_admin: Flags true when the current user is an administrator.

See also

template_preprocess()

template_preprocess_node()

1 theme call to node.tpl.php
node_view in modules/node/node.module
Generate a display of the given node.

File

modules/node/node.tpl.php
View source
<?php

/**
 * @file node.tpl.php
 *
 * Theme implementation to display a node.
 *
 * Available variables:
 * - $title: the (sanitized) title of the node.
 * - $content: Node body or teaser depending on $teaser flag.
 * - $picture: The authors picture of the node output from
 *   theme_user_picture().
 * - $date: Formatted creation date (use $created to reformat with
 *   format_date()).
 * - $links: Themed links like "Read more", "Add new comment", etc. output
 *   from theme_links().
 * - $name: Themed username of node author output from theme_username().
 * - $node_url: Direct URL of the current node.
 * - $terms: the themed list of taxonomy term links output from theme_links().
 * - $submitted: themed submission information output from
 *   theme_node_submitted().
 *
 * Other variables:
 * - $node: Full node object. Contains data that may not be safe.
 * - $type: Node type, i.e. story, page, blog, etc.
 * - $comment_count: Number of comments attached to the node.
 * - $uid: User ID of the node author.
 * - $created: Time the node was published formatted in Unix timestamp.
 * - $zebra: Outputs either "even" or "odd". Useful for zebra striping in
 *   teaser listings.
 * - $id: Position of the node. Increments each time it's output.
 *
 * Node status variables:
 * - $teaser: Flag for the teaser state.
 * - $page: Flag for the full page state.
 * - $promote: Flag for front page promotion state.
 * - $sticky: Flags for sticky post setting.
 * - $status: Flag for published status.
 * - $comment: State of comment settings for the node.
 * - $readmore: Flags true if the teaser content of the node cannot hold the
 *   main body content.
 * - $is_front: Flags true when presented in the front page.
 * - $logged_in: Flags true when the current user is a logged-in member.
 * - $is_admin: Flags true when the current user is an administrator.
 *
 * @see template_preprocess()
 * @see template_preprocess_node()
 */
?>
<div id="node-<?php

print $node->nid;
?>" class="node<?php

if ($sticky) {
  print ' sticky';
}
if (!$status) {
  print ' node-unpublished';
}
?> clear-block">

<?php

print $picture;
?>

<?php

if (!$page) {
  ?>
  <h2><a href="<?php

  print $node_url;
  ?>" title="<?php

  print $title;
  ?>"><?php

  print $title;
  ?></a></h2>
<?php

}
?>

  <div class="meta">
  <?php

if ($submitted) {
  ?>
    <span class="submitted"><?php

  print $submitted;
  ?></span>
  <?php

}
?>

  <?php

if ($terms) {
  ?>
    <div class="terms terms-inline"><?php

  print $terms;
  ?></div>
  <?php

}
?>
  </div>

  <div class="content">
    <?php

print $content;
?>
  </div>

  <?php

print $links;
?>
</div>

Comments

vannus’s picture

if you want control over individual fields:-
(probably best done in a node-mycontenttype.tpl.php file)

comment/delete print $content;

replace with print $field_mycckfield_rendered;.
(you can get the field_mycckfield from the 'Name' column in 'Manage Fields' page of your content type)

- V

greg.harvey’s picture

Actually, control over CCK fields can be gained using CCK's own templates. Copy content-field.tpl.php to your theme directory and copy it again for each field whose mark-up you wish to alter, naming it field-field_name.tpl.php.

So, if I have a field called field_my_field in CCK and I want to modify the mark-up for that field, I copy content-field.tpl.php to my theme directory and then make *another* copy named content-field-field_my_field.tpl.php. I can then change the mark-up in content-field-field_my_field.tpl.php and it will alter the output of that specific CCK field.

No need to touch node.tpl.php!

Rob230’s picture

$node_url is not necessarily the path. If you have Drupal in a subdirectory then the subdirectory will be in $node_url, which makes it not so useful for making a link to the page, since the subdirectory will also appear in $base_url and you won't be able to pass it to url() because you'll end up with the subdirectory repeated.