I am creating a node-content_type.tpl.php template. I have determined how to pull in every piece of data except the image. Here's my code snippit:

cck 2.x-2.2
filefield 6.x-3.0
imagecache 6.x-2.0-beta9
ImageField 6.x-3.0

<?php if ($field_member_logo): ?>
  <div id="member_logo">
    <?php print theme('imagecache', 'logo', $field_member_logo[0]['filepath']); ?>
  </div><!-- /#member_logo -->
<?php endif; ?>

I have a preset in Imagecache named logo. The field $field_member_logo is the field set in cck for the input on this node. There is one and only one image for per entry.

What is the best way to pull this content into the node?

Comments

bluehead’s picture

Go to the admin->Content types->your content type->manage fields and add the field ie. "picture" using filed type - file and widget type - image.
then go to display fields and choose your image_cache preset to display this field for teaser full node rss and others
then go to admin/user/permissions and set the access for created field

Jeff Burnz’s picture

I assume what you are saying is that this is what you are doing but the image is not appearing? If so, then double check you have an image toolkit enabled such as ImageAPI GD2 (enable it in modules) and check your permissions etc.

Snippet looks good, you can also just do this:

<?php if ($field_member_logo): ?>
  <div id="field-member-logo">
    <?php print $node->field_member_logo[0]['view']; ?> 
  </div><!-- /#member_logo -->
<?php endif; ?>

Then manipulate the imagecache preset from the field Display settings.

BTW, its kind of a Drupal convention to use hyphens in class names rather than underscores. Certainly no biggie for your own project though:)

zanlus’s picture

Thanks a ton for your help! It worked like a charm. Is there somewhere that this is explained, e.g. why must you add the ['view']?.

Anyway, I need a little more help, if you don't mind. I'm trying to pull just the body field into the node, but it isn't working with $content. $content pulls everything in. Any suggestions?

Thanks.

zanlus’s picture

Thank you! Danke! Hvala! Gracias! I really need to do more research into CCK so that I don't have to ask these questions. :)