By 2houseplague on
Hi, I'm looking to add a short snippet of code to every node of an existing site. My approach thus far has been to edit node.tpl.php, to place the item like this:
<div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">
<?php if ($picture) {
print $picture;
}?>
<ITEM GOES HERE>
<?php if ($page == 0) { ?><h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2><?php }; ?>
<hr>
<div class="content"><?php print $content?></div>
<?php if ($links) { ?><div class="links">» <?php print $links?></div><?php }; ?>
</div>
When viewing an individual node, this puts the item just below the node title, which is fine.
Example: http://www.websenior.org/node/7705
But my issue is that this approach also displays the item multiple times on category view pages that list the teaser for multiple nodes, which is not desirable.
Example: http://www.websenior.org/nursing-homes-in-louisiana
So what I want is for the item to appear on the node page but NOT on the list page. Much obliged for any help.
Jack
Comments
$page
The $page variable is available to node.tpl.php. It will be set to true if the node is being displayed by itself (i.e., on a page of its own).
http://drupal.org/node/11816
Wrap the code
Wrap the code in:
This says, if the node being displayed is the full page version then execute the code.
Conditional approach makes
Conditional approach makes perfect sense, but the code returned an error on line 6, "unexpected '<'"...
do this
do this instead.
Small error in the above code.
The paranthesis "}" is not required.delete it,and the code should work fine.It should be
oh yeah :p i just copied and
oh yeah :p i just copied and pasted it from my previous post and forgot to delete it.
That works perfectly.
That works perfectly. Thanks!