Tuesday, May 21 2013
How to print fields on a NODE TPL (node-video.tpl.php, for example)
Drupal 6
Some examples:
<?php print $title; ?>
<a href="<?php print $node_url ?>"><?php print $title; ?></a>
<?php if (!empty($field_news_image)) {
print $field_news_image['0']['view'];
} ?>
<\div class="submitted">
<?php print format_date($node->created, 'custom', 'j F Y'); ?>
</div>
<\div class="field venue">
<?php print l(($node->field_venue[0]['value']), $node->field_venue_url[0]['value']); ?>
</div>
<\div class="field btn-tickets ticket-link">
<?php
if($node->field_sold_out[0]['Yes']){
print t('Sold out'); }
else {
print l(t('Tickets'), $node->field_ticket_sales_url[0]['value'], array('class' => 'buy-tickets')); }
?>
</div><?php print $title; ?>
<a href="<?php print $node_url ?>"><?php print $title; ?></a>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Print the complete CCK Link field:
<?php print $node->field_listing_website[0]['view'] ?>
Or separate the URL from the title:
<?php
$link_url = $node->field_link[0]['url'];
$link_title = $node->field_link[0]['title'];
?>
<div<?php print $node_attributes; ?>>
<?php if (!empty($link_url)) : ?>
<a href="<?php print ($link_url); ?>">
<?php endif; ?>
<\h2 class="node-title"><?php print $title; ?><\/h2>
<?php print $content; ?>
<?php if (!empty($link_url)) : ?>
</a>
<?php endif; ?>
</div>
This is also explained pretty well here: http://www.caucusllc.com/blog/theming-a-cck-node