Closed (fixed)
Project:
ImageField
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Aug 2007 at 07:40 UTC
Updated:
12 May 2008 at 20:09 UTC
I've managed to figure out how to display the first image of a node teaser at the beginning using contemplate:
<?php print $node->field_image[0]['view'] ?>
I'd like the remaining images to appear after the teaser text. I can get all the images to display at the end of the text using:
<div class="imageBlock">
<?php foreach ((array)$field_image as $item) { ?>
<div class="image">
<?php print $item['view']; ?>
</div>
<?php } ?>
<br class="clearall" />
</div>
My problem is how do I get it to skip field_image[0]. I figure I need to test if something is > 0, but don't know what to use. Any help would be greatly appreciated. My apologies if I'm posting this in the wrong area. I'm fairly new to this.
Comments
Comment #1
yched commentedprint $item['view'];?>
Comment #2
yched commentedheh, PHP code filter does not like embedded HTML...
Comment #3
ericprk commentedWorked great! Thanks for the help.
Comment #4
(not verified) commentedComment #5
bobdalob commentedThis is a useful snippet however when used with content types with optional images, image-free nodes will show the unattractive 'image not found' in place of the 'first' image.
Comment #6
Rob T commentedThanks for the snippet, yched... it helped a great deal.
Comment #7
rick hood commentedRegarding #5 above:
I solved this by checking to see if the variable was empty and only print it if its not empty:
The PHP empty function is here:
http://www.php.net/manual/en/function.empty.php
Comment #8
rick hood commentedSorry spoke too soon...
The above (#7) doesn't work. Back later when I figure it out...
Comment #9
rick hood commentedOK, this works:
Comment #10
dopry commentedgo do theme snippet development and docs in the handbook where people can find it later...
Comment #11
Jeff Burnz commentedold reliable way I have always done this
edit - sorry, pasted wrong code... my bad, this one uses !empty...