Viewer Options (Advanced: Random ?)

5 posts by 2 authors in: Forums > CMS Builder
Last Post: May 8, 2009   (RSS)

Re: [virgodesign] Viewer Options (Advanced: Random ?)

By ross - May 8, 2009

Hi there.

Thanks for posting!

In your viewer code, find this line:

'where' => whereRecordNumberInUrl(1),

right above that add in:

'orderBy' => 'RAND()',

That will randomly sort your records. Technically, it actually randomly sorts even when you do have a number in your URL but there is only one record for it to randomize so it works ok. When you don't have a number, it randomly picks one from the whole list of records.

Give it a shot and let me know what you think :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Viewer Options (Advanced: Random ?)

By avrom - May 8, 2009

Ross,

or how about just 'where' => 'RAND()',

Would that do the same thing as well ? A random record if no number in URL, but if there is a number in the URL it would grab the record number ?

Cheers and Thanx !

Re: [virgodesign] Viewer Options (Advanced: Random ?)

By ross - May 8, 2009

Hi

That probably won't work as there wouldn't be anything there to take care of pages that do have the number there. You'll want to use that other option in my previous post.

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Viewer Options (Advanced: Random ?)

By avrom - May 8, 2009

Okay got it :)) Many thanks...