Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Random order DataObject front end


Reply

11 Posts   4949 Views

Avatar
pinkp

14 May 2011 at 10:57am Community Member, 168 Posts

many thanks!!!!!! worked like a charm, although it had a syntax error at first the function needed to be:

function RandomSlideshowItems() {
return DataObject::get("SlideshowItem", "", "RAND()", "");
}

I guess I should do a few more basics! thanks for the rapid response.

-----

On another note is it possible to limit the amount of data objects that are pulled from the DB, i.e. I upload 10 images but only 5 random images are chosen to be shown in the slideshow?

Avatar
UncleCheese

15 May 2011 at 4:00am 4085 Posts

The fifth argument is the limit.

Avatar
pinkp

16 May 2011 at 12:31am Community Member, 168 Posts

Changing the code to this allowed me to display a limited number of images sourced from my uploads and chosen at random. The result is a slideshow which will always have varied content, perfect!

function RandomSliders($num = 3) {
return DataObject::get("Slider", "", "RAND()", "",$num);
}