|
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 |
gazzahbay Smarty n00b
Joined: 13 Jun 2016 Posts: 1
|
Posted: Mon Jun 13, 2016 3:37 am Post subject: Using SHUFFLE for simple carousel |
|
|
Hi Team
Have below code for a simple folder-based carousel.. However wish to put a URL link beside each image - say they are Sponsor Links..
Code: | $images = array_values( preg_grep( '/^((?!thumb).)*$/', glob('uploads/images/sponsors/*{*.jpg,*.gif,*.png}', GLOB_BRACE) ) );
echo "<ul>\n";
shuffle($images);
foreach ($images as $image) {
echo "<li><img src='$image' style='height:80px !important' alt='' /></li> \n";
}
echo "</ul>\n"; |
I can see a whole new approach - as in listing each image individually inside the URL..
EG
Code: |
<ul>
<li> <a href="/something.html"><img src="something"></li>
<li> <a href="/something2.html"><img src="something2"></li>
<li> <a href="/something3.html"><img src="something3"></li>
<li> <a href="/something4.html"><img src="something4"></li>
<li> <a href="/something5.html"><img src="something5"></li>
</ul>
|
Any Hints on how to achieve this?
Cheers |
|
Back to top |
|
djmassive Smarty n00b
Joined: 17 Jan 2010 Posts: 3
|
Posted: Thu Jun 30, 2016 11:45 am Post subject: |
|
|
You need to pass to smarty using $smarty->assign('array' , $array) with files then use {foreach item=item from=$array} - simply the best way |
|
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
|