Jump to:

794 Posts in 408 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » random content widget

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1388 Views
  • bebabeba
    Avatar
    Community Member
    192 Posts

    random content widget Link to this post

    hi!
    I have a page taht take data from external database about product. This page show product's photo, some row of text adn a 'detail' button (when I ckick on this button I show all product characteristic).
    I need a widget to show randomly one of this product every week. (only product name and a link to that product page)
    Can I use random content widget?or something else?
    thanks!

  • UncleCheese
    Avatar
    4085 Posts

    Re: random content widget Link to this post

    Assuming your product class name is Product and the fields you want are Title and Link...

    Page_Controller extends Content_Controller
    {
    function RandomContent()
    {
    return DataObject::get_one("Product",null, false, "RAND()");
    }
    }

    and on any page

    <% control RandomContent %>
    $Title $Link
    <% end_control %>

    1388 Views
Page: 1
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.