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.

Customising the CMS /

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

Limiting and/or randomizing related content


Go to End


2 Posts   1491 Views

Avatar
pingu

Community Member, 75 Posts

11 May 2009 at 4:34am

Hi,

Is there a way to limit and randomize related content?

I have a site where products can have up to 4 related products. These are selected via a complextablefield.
Currently, all selected related products are display. I'd like to know how I can:

1. Limit these to show only 4
2. If possible, show 4 random ones from all which have been selected.

Avatar
PGiessler

Community Member, 47 Posts

11 May 2009 at 7:32pm

Hello,

I think there is a way to limit and randomize related content. You have to edit your SQL-Request ( DataObject::get), because you can write an optional parameter (limit). Furthermore you can create an easy random function in mysite/code , which the DataObject will randomize.

If you don't know what I suppose, you can show me your source code. So I can look at this!

Best regards,

Pascal