eZ Community » Forums » Setup & design » Navigate through related images
expandshrink

Navigate through related images

Navigate through related images

Tuesday 18 November 2008 12:58:32 pm - 3 replies

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!

Modified on Tuesday 18 November 2008 9:41:24 pm by Robert Malevic

Wednesday 19 November 2008 8:53:29 am

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

Wednesday 19 November 2008 9: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!!!

Modified on Wednesday 19 November 2008 9:07:24 am by Robert Malevic

Thursday 04 October 2012 2:02:12 pm

Thanks a lot Maxime!

I try "liking", but I get an error

Modified on Thursday 04 October 2012 2:03:21 pm by Andreas Wiik

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from