Discussions

Print field_images field tpl in node

Hy,

i try the following and it works:

<?php
 
print render($content['product:field_images']);
?>

I need now, to be able to address each image and print some stuff inside the tag, so i tried:

<?php
$my_images
= $node->field_images;

if (
count($my_images)>0) :
  foreach (
$my_images as $my_image) :
   
$image = theme('imagecache', 'product_full', $my_image['filepath'], $my_image['data']['alt'], $my_image['data']['title']);
    print
$image;
  endforeach;
endif;
?>

But it doesn´t work. Any suggestions?

Is that the right way, or am i totally off track?

Best Sam

Tags: 
Posted: Mar 21, 2013

Comments

realskorpion on March 21, 2013

Hi

Could you explain a little more what do you want to achieve?
Maybe you can do it without modify the .tlp file
Are you using commerce kickstart 2.0?
There's a way to activate the alt and title field for images without modify the .tpl
file that's why I asked you about what do you want to do

Thanks

sammyfm on March 21, 2013

Hy realskorpion, what i want is to implement google´s rich snippets, that means i need to set up a code for the first image that´s available. Images for products are created with max 3 different images, so it would be perfect to implement the rich snippet in the first one only. Ideally there would be a way to print image01, image02, image03 (if available) and than add the rich snippet code to the first one.

I´m using latest commerce kickstart 2.0