Forums / Setup & design / Show folders from the gallery on frontpage
Alexander Davidsen
Friday 20 July 2007 2:41:44 pm
i'm trying to add a list of the four newst folders in my gallery. I'm going to put the code in the frontpage override. I have been using this code for showing the latest folders made in the gallery section:
{def $nodes=fetch( 'content', 'list', hash( 'parent_node_id', 178, 'depth', 1, 'limit', 4 ) )} {foreach $nodes as $node} <a href="{$node.url}"> {$node.name|wash}</a> <br /> {/foreach}
So this part works.
What I want to do is to show the newest folders, but in stead of showing just the link I want to show a random picture form that folder. A the nature gallery should get a random picture from its own gallery, the same goes for the other ones. The random picture is not so important, but every album should have its own picture.
Is this possible, and if, how can I solv this?
- Alexander
Łukasz Serwatka
Monday 23 July 2007 6:43:35 am
1. Fetch 4 items filtered on content class ('gallery' in your case) 2. Loop through fetch result array3. Display image as child of gallery object
{foreach ...} {* Inside foreach loop *} {def $rand_img = rand( 0, $item.children_count )} {attribute_view_gui attribute=$item.children[$rand_img].data_map.image} {undef $rand_img} {/foreach}
Of course you need to fix variable names up to your code.rand tpl operator is available since Exponential 3.8
Personal website -> http://serwatka.net Blog (about eZ Publish) -> http://serwatka.net/blog
Monday 30 July 2007 5:49:30 am
Worked like a charm!
Thanks for your help!
Tuesday 31 July 2007 4:12:07 am
Great, you are welcome! ;)