Shortest random image method
Seen lots of debate over random image methods, here's one for the pot
If your on x-cart 3.3.8 or over use Code:
[img]yoursitepath/image{[/img] hows this work? Notice the image{"1"|mt_rand:5}.gif Generating a random number between 1 and 5 using smarty so in the html it's image5.gif or image3.gif etc etc Simply name your images image1.gif, image2.gif, image3.gif etc and set the mtrand:X to the amount you have in the folder. If your running on an older x-cart then the smarty that is installed doesnt support the random function. |
...And if are running an older version of X-cart less than version 3.3.8:
Save the following code to Smarty-2.1.1/plugins/function.random.php. :!: Note your Smarty-2.1.1 directory may differ. Code:
<? How to use it in .tpls? Code:
{random min=0 max=10}, {random min=-10}, {random max=20} or just {random} Kudos! |
Quiet a old post but the random image method given by
groovico still works great for me. Because I want to have different images than the product or detailed images random loaded. But I also would like it to load several images at the same time and on the same page, and in a way there are no duplicate images loaded. Would that be possibe? Furthermore, is there a way to make the random loaded images clickable, so that clicking on them will open the corresponding product page? I hope that somebody can help or knows another way to load clickable images other than the product or detailed images. Thanks in advance! |
Wow, this is so easy to do its amazing. I was researching how to add a bunch of javascript to do this for the last couple hours until I found this post.
Excellent, fantastic, amazing, easy. thank you thank you thank you |
|
Quote:
You don't need it for my example above, it's not javascript, it's done in smarty. |
Sorry, is for the link that I post, it use Java
|
All times are GMT -8. The time now is 08:24 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.