Posted by Sam Moore on November 14, 2012 at 7:01pm
My client wants a random image from a collection to appear in a block, and to persist there until the page is reloaded (or the user's next visit).
Does anyone know if Views can do this? Or am i better off writing my own JavaScript routine to hide all the images and randomly show one?
There were some modules such as Views Javascript Random and Random Images that looked promising, but so far I haven't found anything for D7.
Ideally I'd like to keep tis functionality in a module or in Views, so as to enable an Admin to make changes, but if it can't be, so be it.
Comments
One approach is to use a
One approach is to use a content type with an image field, this way the client can define the set of images.
Then uses views to show the image from one node of this content type and set the sort order to random.
Great idea
Thanks for that - I'll give it a try.
Gotta love Views :-)
http://resonetrics.com
http://technologyformarketers.com
http://kittenassociates.org
http://www.linkedin.com/in/sammooreatresonetrics
Update
Just an update - this did work - thanks for that - but I have a discussion to have with the client around caching. Specifically, all users are getting the same page until the cache expires. That is after all how caching works.
I don't think there's an answer for this - they may have to forgo either the randomness or the caching (which after all is sort of conceptually antithetical to randomness, eh?)
Anyway thanks for the fix.
http://resonetrics.com
http://technologyformarketers.com
http://kittenassociates.org
http://www.linkedin.com/in/sammooreatresonetrics
I seem to recall an "ajax
I seem to recall an "ajax block" module that would let you keep the page caching while still having a random image.
Boost
Actually I figured out that Boost lets you exclude pages from the caching scheme - so I'll give that a try. On this site, isn't particularly slow, so hopefully that'll be OK.
Thanks for your help on this!
http://resonetrics.com
http://technologyformarketers.com
http://kittenassociates.org
http://www.linkedin.com/in/sammooreatresonetrics
I use boost and the ajax
I use boost and the ajax block module.
Boost caches the entire page but for various blocks you might not want cached, you can enable ajax.
For instance I use ajax for a block filled with trending articles as well as the top 10 latest articles.
Works great.