I'm trying to get a specific image ($FeaturedImage) from every grandchild page (GalleryPage.ss) of my Portfolio Page (PortfolioPage.ss) and display them in a random order.
I can get the images using the template easily enough. PortfolioPage.ss
<% loop Children %>
<% loop Children %>
<% loop FeaturedImage %>
<img src="$Url"></>
<% end_loop %>
<% end_loop %>
<% end_loop %>
But this will display them in the order of the pages in the menu.
After some research it seems best to create a function in the page controller, but I'm not sure how to write this.. (anyone with a link to documentation / tutorials on these would also be great).
Examples of similar code found so far: get Dataobjects from Children - SilverStripe 3.1 http://www.silverstripe.org/template-questions/show/23296
Silverstripe docs: http://doc.silverstripe.org/framework/en/topics/datamodel
I'm just not sure how to apply this to my code..thanks