Node.tpl.php | drupal.org

Node.tpl.php

This template controls the display of a node, and a node summary. It can only affect the output of the $content variable.

Available variables

$content
Node content, teaser if it is a summary.
$date
Formatted creation date.
$directory
The directory the theme is located in, e.g. themes/garland or themes/garland/minelli.
$id
The sequential ID of the node being displayed in a list.
$is_front
True if the front page is currently being displayed.
$links
Node links.
$main (4.6)
True if the node is appearing in a context, like the front page, where only the teaser should be shown. No longer used in 4.7 and later.
$name
Formatted name of author.
$node (object)
The node object. To view all of the properties of a current $node object, put the following line of code in your node.tpl.php: <pre><?php print_r($node); ?></pre>
$node_url
Link to node.
$page
True if the node is being displayed by itself as a page.
$picture
HTML for user picture, if enabled.
$sticky
True if the node is sticky.
$submitted
Author and create date information, if the node info display is enabled for this node type.
$taxonomy (array)
array of HTML links for taxonomy terms.
$teaser
Boolean to indicate whether to return the teaser rather than the full node text.
$terms
HTML for taxonomy terms.
$title
Title of node.
$zebra
Alternates between odd/even in a list.

Tips: Print out available variables

Print the variables array

<?php
print '<pre>';
print_r(get_defined_vars());
print
'</pre>';
?>

Print the variables array with the HTML markup

<?php
print '<pre>';
print
htmlspecialchars(print_r(get_defined_vars(), TRUE), ENT_QUOTES);
print
'</pre>';
?>

Default template for 5.x

<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clear-block">

<?php print $picture ?>

<?php if ($page == 0): ?>
  <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>

  <div class="meta">
  <?php if ($submitted): ?>
    <span class="submitted"><?php print $submitted ?></span>
  <?php endif; ?>

  <?php if ($terms): ?>
    <span class="terms"><?php print $terms ?></span>
  <?php endif;?>
  </div>

  <div class="content">
    <?php print $content ?>
  </div>

<?php
 
if ($links) {
    print
$links;
  }
?>

</div>


Node.tpl.php | drupal.org

Blogged with the Flock Browser

Tags:

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s

%d blogueurs aiment cette page :