Snippets » Database Retrievals » Displaying Fields From a Set of Pages on Another Page
25
May
1
Displaying Fields From a Set of Pages on Another Page
Although ultimately requiring very little code, displaying data from a set of pages on another page can seem confusing for those new to SilverStripe. This example will display all of the Images from all the staff pages on our current page. This works by first returning all the staff pages to our template and cycling through each of them, drawing the Image for each one.
Add the following function to your current pages Controller:
Then inside your template you can simply cycle through the results using <% control GetStaffPages %> like so:
Of course this can be taken a lot further, creating filters or sorts in the DataObject::get() call or adding conditions in the template.
Thanks to Moreno for suggesting this snippet.
About the Author
Name: Aram Balakjian
Website: http://www.aabweb.co.uk
Aram is a web designer/developer running London based agency aab web. He has a strong passion for developing attractive, usable sites around the SilverStripe CMS.
Comments (1)
-
Wow thanks for this so simple and obvious can't believe I didn't think of it. Very helpful!
Posted by Liam, 30/01/2010 3:37am (6 months ago)
RSS feed for comments on this page RSS feed for all comments