7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Random order DataObject front end
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 3625 Views |
-
Re: Random order DataObject front end

14 May 2011 at 10:57am
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?
-
Re: Random order DataObject front end

16 May 2011 at 12:31am
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);
}
| 3625 Views | ||
| Go to Top |

