Hi.

I am trying to place an imagefield image directly to the right of the node title of a Story, but don't really know how to hook into it. It would be great if I could access it directly from node.tpl.php, something like this:

...
<?php if ($imagefield && $type=="story") { print "<img src=\"$imagefield\" align=right>"; } ?>
<h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2>
...

Comments

yched’s picture

Status: Active » Fixed

You can use the $<FIELD_NAME_rendered variable in your node template.
Since the imagefield is already rendered with all the contents of the node in the $content variable, you'll probably need to check the 'exclude' checkbox for the field on CCK's 'Display Fields' screen, so that you don't end up with duplicate display.

For more informationn, install advanced_help module and see the 'Theming CCK data in nodes' section in CCK's help pages.

hba’s picture

Thanks! If others are interested, here's what I did:

1) Read the theming guide, available under modules/cck/help/theme-node-templates.html

2) Created my image field on Story, with name "field_nodeimage"

3) Copied node.tpl.php to node-story.tpl.php in my theme. Edited node-story.tpl.php and added near the top:

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

4) Edited my style.css to make "field-field-nodeimage" float to the right:

.field-field-nodeimage {
  float:right;
}
green monkey’s picture

thank you for the above post

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.