Jump to content

Image link again


Recommended Posts

I have product with 4 images. How i can get link on the second or third image of the product, not for the cover. Maybe i need to use "position" value? But how it works?

Thx!

 

where you want to get these images? everything depends on it.

Link to comment
Share on other sites

i have this standart code in product.tpl, it shows all thumbnails, but how i can show only second (by position) or another thumbnail?


{foreach from=$images item=image name=thumbnails}
{assign var=imageIds value="`$product->id`-`$image.id_image`"}
<li id="thumbnail_{$image.id_image}">
<a href="{$link->getImageLink($product->link_rewrite, $imageIds, 'thickbox_default')|escape:'html'}" rel="other-views" class="thickbox{if $smarty.foreach.thumbnails.first} shown{/if}" title="{$image.legend|htmlspecialchars}">
<img id="thumb_{$image.id_image}" src="{$link->getImageLink($product->link_rewrite, $imageIds, 'medium_default')|escape:'html'}" alt="{$image.legend|htmlspecialchars}" height="{$mediumSize.height}" width="{$mediumSize.width}" />
</a>
</li>
{/foreach}
Edited by MAMAY (see edit history)
Link to comment
Share on other sites

you can use simple if condition with foreach iteration 

 
{if $smarty.foreach.thumbnails.iteration==2}
<li id="thumbnail_{$image.id_image}">
<a href="{$link->getImageLink($product->link_rewrite, $imageIds, 'thickbox_default')|escape:'html'}" rel="other-views" class="thickbox{if $smarty.foreach.thumbnails.first} shown{/if}" title="{$image.legend|htmlspecialchars}">
<img id="thumb_{$image.id_image}" src="{$link->getImageLink($product->link_rewrite, $imageIds, 'medium_default')|escape:'html'}" alt="{$image.legend|htmlspecialchars}" height="{$mediumSize.height}" width="{$mediumSize.width}" />
</a>
</li>
{/if}

this code will show only second image

Link to comment
Share on other sites

 

you can use simple if condition with foreach iteration 

 
{if $smarty.foreach.thumbnails.iteration==2}
<li id="thumbnail_{$image.id_image}">
<a href="{$link->getImageLink($product->link_rewrite, $imageIds, 'thickbox_default')|escape:'html'}" rel="other-views" class="thickbox{if $smarty.foreach.thumbnails.first} shown{/if}" title="{$image.legend|htmlspecialchars}">
<img id="thumb_{$image.id_image}" src="{$link->getImageLink($product->link_rewrite, $imageIds, 'medium_default')|escape:'html'}" alt="{$image.legend|htmlspecialchars}" height="{$mediumSize.height}" width="{$mediumSize.width}" />
</a>
</li>
{/if}

this code will show only second image

 

Thank you! It solve my problem, but i think it must be more best way.

Link to comment
Share on other sites

well, to be honest, you have to use foreach loop because you've got images array in variable: $images

and to display second/third etc. images you have to check iteration, there is no other way, unfortunately.

Thank you very much!!! :) Problem is solved

Link to comment
Share on other sites

×
×
  • Create New...