Hi,
I'm trying to make a "more articles" type of box for my content pages. I'm using a modded menu template to do this, so the call to the menu manager is as follows:
{menu template='minimalmenu' start_element="2.1" show_root_siblings="1"}
It will only show sibling articles, which is what I want.
The problem is, it is listing all articles. I want it to just show, say, the top 5 articles then a "View All" link. I'm trying to mod the minimalmenu template to do this, but I'm new to smarty and am having trouble.
Essentially, I want the foreach loop to only loop 4 times then quit. How can this be done?
Any help would be appreciated.
Thanks and regards,
Jazz
Limiting a foreach loop to 4 iterations only
Re: Limiting a foreach loop to 4 iterations only
Look here:jazz wrote: Essentially, I want the foreach loop to only loop 4 times then quit. How can this be done?
Code: Select all
{foreach from=$myArray item=i name=foo}
{if $smarty.foreach.foo.iteration < 5}
.....
loop
.....
{/if}
{/foreach}
Re: Limiting a foreach loop to 4 iterations only
Ok next problem I'm having.
At the end of the iterations, I'm tyring to display a "View All" link which links to the parent page of the pages I'm displaying in the menu.
So, I'm calling the menu template as follows:
{menu template='minimalmenu' start_element="2.1" show_root_siblings="1"}
In this minimalmenu template, I want to put in a hyperlink that links back up to what would essentially be start_element="2".
Is that possible?
Thanks.
At the end of the iterations, I'm tyring to display a "View All" link which links to the parent page of the pages I'm displaying in the menu.
So, I'm calling the menu template as follows:
{menu template='minimalmenu' start_element="2.1" show_root_siblings="1"}
In this minimalmenu template, I want to put in a hyperlink that links back up to what would essentially be start_element="2".
Is that possible?
Thanks.
Re: Limiting a foreach loop to 4 iterations only
This is as variable (get_parent_alias) in CGSimpleSmarty modulejazz wrote: In this minimalmenu template, I want to put in a hyperlink that links back up to what would essentially be start_element="2".
Alby
Re: Limiting a foreach loop to 4 iterations only
Great, thanks. It turns out the function I needed was get_root_alias.