Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Random order DataObject front end

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 4445 Views
  • pinkp
    Avatar
    Community Member
    168 Posts

    Re: Random order DataObject front end Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Random order DataObject front end Link to this post

    The fifth argument is the limit.

  • pinkp
    Avatar
    Community Member
    168 Posts

    Re: Random order DataObject front end Link to this post

    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);
    }

    4445 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.