Hi,
in my template file I want to check if there is one or more images set for the product - to avoid that the following code is taken over to the output:
<?php if (!empty($node->field_image_cache)): ?>
<?php // main picture
$imagePath = $node->field_image_cache['0']['filepath']; ?>
<a href="<?php print base_path() . "sites/default/files/imagecache/product_full/" . $imagePath; ?>" rel="lightbox[prod]">
<img src="<?php print base_path() . "sites/default/files/imagecache/product/" . $imagePath; ?>" alt="<?php print $title?>" title="<?php print $title?>" /></a>
<?php // other pictures ?>
<ul class="other_imgs">
<?php foreach ($node->field_image_cache as $images) { if ($images['filepath'] != $imagePath) { ?>
<li><a href="<?php print base_path() . "sites/default/files/imagecache/product_full/" . $images['filepath']; ?>" rel="lightbox[prod]" title="<?php print $title; ?>">
<img src="<?php print base_path() . "sites/default/files/imagecache/uc_thumbnail/" . $images['filename']; ?>" alt="<?php print $title; ?>" /></a> </li>
<?php } } ?>
</ul>
<?php endif; ?>
If there is no image for the product this leads to the following output:
<a href="/seeliger/sites/default/files/imagecache/product_full/" rel="lightbox[prod]">
<img src="/seeliger/sites/default/files/imagecache/product/" alt="Eyeliner waterproof" title="Eyeliner waterproof" /></a>
<ul class="other_imgs">
</ul>If there is just one image set it leads to the following output:
<a href="/seeliger/sites/default/files/imagecache/product_full/sites/default/files/200130_duo.jpg" rel="lightbox[prod]">
<img src="/seeliger/sites/default/files/imagecache/product/sites/default/files/200130_duo.jpg" alt="Fuß-Schaum-Creme Intensivpflege Plus 125 ml" title="Fuß-Schaum-Creme Intensivpflege Plus 125 ml" /></a>
<ul class="other_imgs">
</ul>If there are two or more images set it is ok - the first main image is shown correctly and the output of the further images in a HTML list is as it should be. Just the output in case that just one or no image is set is incorrect. Can anybody help with "if"-statement I can check for the product images?
Thank you very much in advance!
Best,
Tobias
