Forums / Setup & design / Navigate through related images
Robert Malevic
Tuesday 18 November 2008 3:58:32 am
Hi All,
I need a template which should display related images one at the time.I use this code to fetch related images and to display the first image:
{foreach $node.data_map.images.content.relation_list as $relatedImage} {def $obj=fetch('content', 'object', hash('object_id', $relatedImage.contentobject_id))} {attribute_view_gui attribute=$obj.data_map.image image_class='original'} {undef $obj} {break} {/foreach}
My problem is that in the loop above I need a break else all related images will be shown. What I want to do is fetch all related images, show the first image and add navigation to navigate through the other images.I tried to access the related images separately but somehow I am only able to display all related images.
Any suggestions how to navigate through each related image separately?
Thanks!
Maxime Thomas
Tuesday 18 November 2008 11:53:29 pm
Hi,
I'm not sure your code is the best way to reach your aim.I would have done this like this :
{def $count=$node.data_map.images.content.relation_list|count() $offset=0 $object='' } {if $view_parameters.offset} {set $offset=$view_parameters.offset} {/if} {def $obj=fetch('content', 'object',hash('object_id', $node.data_map.images.content.relation_list[$offset].contentobject_id))} {attribute_view_gui attribute=$obj.data_map.image image_class='original'} {undef $obj} {if $offset|gt(0)} <a href="{$node.ul_alias|ezurl('no')}/(offset)/{$offset|dec()}">Previous</a> {/if} {if $offset|lt($count)} <a href="{$node.url_alias|ezurl('no)}/(offset)/{$offset|inc()}">Next</a> {/if}
Cheers
Maxime Thomas [email protected] | www.wascou.org | http://twitter.com/wascou Company Blog : http://www.wascou.org/eng/Company/Blog Technical Blog : http://share.ez.no/blogs/maxime-thomas
Wednesday 19 November 2008 12:06:17 am
Hi Maxime,
Your solutions works and is exactly what I was looking for. Hopelfully more inexperienced programmers like me can benefit from it.
Thanks!!!