A quick trick to display a random image

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
cnymike
Power Poster
Power Poster
Posts: 446
Joined: Sun Jan 22, 2006 3:24 am

Re: A quick trick to display a random image

Post by cnymike »

What version of smarty is being used in CMSMS? I wanted to download the correct doc file from smarty.net but did not see a version of docs for 2.60 which seems to be the version in current use with CMSMS.

So which version from here...  http://www.smarty.net/download-docs.php  would be the most appropriate version of the documentation to get?
alby

Re: A quick trick to display a random image

Post by alby »

cnymike wrote: What version of smarty is being used in CMSMS? I wanted to download the correct doc file from smarty.net but did not see a version of docs for 2.60 which seems to be the version in current use with CMSMS.

So which version from here...  http://www.smarty.net/download-docs.php  would be the most appropriate version of the documentation to get?
In CMSMS there is 2.6.18 version
2.6.14 documentation it's ok, nothing has changed in functions

Alby
Andrew Prior
Forum Members
Forum Members
Posts: 247
Joined: Sun Oct 28, 2007 4:14 am
Location: Australia

Re: A quick trick to display Several random images

Post by Andrew Prior »

I used this piece of code on a site which had three little images in a left hand column under the menu. I thought
"Why not use some random images." So I put the code in three times, which works except sometimes you would get the same images showing.  So I changed the code like this: (still with 10 images)

{capture assign='num'}{1|rand:8}{/capture}
and I put this before the code for the images.

Then for the images I have the following:

Now no more duplicates.  Nothing very smart from a programmer's perspective, but I was pleased.  :)

Andrew
Pierre M.

Re: A quick trick to display a random image

Post by Pierre M. »

Thank you for the tip, Andrew.
Feel free to write it in the wiki with your forum account.

Have fun with CMSms !

Pierre M.
elkman
Power Poster
Power Poster
Posts: 262
Joined: Thu Jan 11, 2007 9:16 pm
Location: Colorado

Re: A quick trick to display a random image

Post by elkman »

This is an old post but this technique works great. I have been using this to offer a different background image each time a page is loaded.

Can anyone suggest a go way to preload the background images used? These are fairly large and my understanding is the browser will look for the preloaded image only if it has an identical path.

I've tried several different CSS methods without success that I attribute to using the [[root_url]] coding in the style sheet which doesn't match the image path in the template.

Thanks for looking,
Elkman
Post Reply

Return to “Tips and Tricks”