I have a content type that has a CCK image field. Lots of these images are displayed in a View as thumbnails. The template for each image is views-view-field.tpl.php. How can I theme the contence of this file?

The default is <?php print $output; ?> which prints the Imagecache preset of the CCK image field. How can I print this field by itself so I can add other PHP and html around it?

Ive been looking in the forums for hours and none of the code seems to work for me. I can also cant figure out how to print all the variables (or whatever form the contense is in).

Thanks

Comments

gaurav_m’s picture

Try this
if that works for you - http://drupal.org/project/contemplate

Happy Juggling!

jdln’s picture

Yes, ive tried using Content Templates. Ive used it before and its been very helpful, however copying the php print stuff into my template doesnt work for me. I either get nothing or a lots of text that looks a like a very long error message.

Id like to print all the available variables in the hope i can see whats going on or what i need to call.

jdln’s picture

Should one of these print the node's title?;

<?php print $fields['field_title']->content; ?>
<?php print $fields['title']->content; ?>

And I tried this from the Content Template module;

<?php print check_plain($node->title) ?>
jdln’s picture

Ive found that this;

<?php print $row->{$field->field_alias}; ?>

Prints the variable node_data_field_image_upload_field_image_upload_fid as a number.

The only filed in my view is image_upload, so I think the number relates to the image in that field. How can I print this filed as an image rather than as number?

kostask’s picture

Edit the view, go to the cck image field and go to format. From there you can select whatever is more relevant to you (path to file, url to file, etc).

Another way is to theme it via a tpl.php file. Just print_r($row) and use what you need.

Or use the module Drupal for firebug, plus firebug and drupal for firebug Firefox addons and locate the variable you need using those. It might take some minutes to setup, but it will make your life easier if you are playing with tpl.php files.

jdln’s picture

Thanks. Didnt know there was a Drupal Firebug!