|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
bughy84 Smarty n00b
Joined: 18 Sep 2013 Posts: 1
|
Posted: Wed Sep 18, 2013 1:29 pm Post subject: Random section loop |
|
|
Hi,
i have this code:
Code: | {section name="id_firm" loop=$a_firm_display max=5}
<a href="{$smarty.const.HOST}{$a_firm_display[id_firm].url_rewriting}"><img src="{$a_firm_display[id_firm].firm_logo}" /></a>
{/section} |
I can't figure how to make them show random. That code display 50 images with links. But i need to show only 5 (i used max=5) and i need to be random (on each refresh of the page to show 5 random images)
Can someone help me please?
Thx in advance |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Sep 18, 2013 4:31 pm Post subject: |
|
|
See PHP function array_rand
Code: | {foreach array_rand($a_firm_display,5) as $i}
<a href="{$smarty.const.HOST}{$a_firm_display[$i].url_rewriting}"><img src="{$a_firm_display[$i].firm_logo}" /></a>
{/foreach} |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|