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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Widgets /

Discuss SilverStripe Widgets.

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

random content widget


Go to End


2 Posts   2750 Views

Avatar
bebabeba

Community Member, 193 Posts

22 January 2009 at 12:33am

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!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

22 January 2009 at 3:36am

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 %>