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

Display Content from Random child Page (based on Count)


Go to End


10 Posts   4957 Views

Avatar
tobych

Community Member, 97 Posts

10 November 2009 at 6:49pm

Linsey,

You're not actually getting a random child of a particular page here, of course. You're getting a random instance of a particular class. That's fine if all instances share the same parent.

I've just used this code to generate a random testimonial on a home page: pretty much the same use case as you have, it appears.

I can't offer code to produce a random child right now, as I'm too trying to get a site ready. Just wanted to warn people.

Toby

Avatar
biapar

Forum Moderator, 435 Posts

11 November 2009 at 12:04am

I confirm this:

"You're not actually getting a random child of a particular page here, of course. You're getting a random instance of a particular class. That's fine if all instances share the same parent. "

Because tested... -:)

Bye

Go to Top