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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

reverse order of posts

Go to End

3 Posts   2632 Views


Community Member, 36 Posts

4 August 2009 at 11:48pm

Currently I have a portfolio page and it shows all the images except the most recently added page is displayed as the last image on the page. (i uses pages and call them using 'childern' in to the portfolio.) I want it so its the very first image and as you scroll down the images get older in order of when they were created.

This is how I am calling them:

    <% control Children %>
		<div id="port_box">
			<span class="port_type">
			<span class="port_title_type">Client:</span> $Client</span>
			<span class="port_type"><span class="port_title_type">Project:</span> $Task</span>
			<span class="port_type"><span class="port_title_type">Role:</span> $Role</span>
			<span class="port_type"><span class="port_title_type">Summary:</span> $Content</span>
    <% end_control %>

 * Defines the PortfolioHolder page type
class PortfolioHolder extends Page {
   static $db = array(
   static $has_one = array(
   static $allowed_children = array('PortfolioPage');
   static $icon = "themes/tutorial/images/treeicons/news";
class PortfolioHolder_Controller extends Page_Controller {

function rss() {
  $rss = new RSSFeed($this->Children(), $this->Link(), "The coolest news around");
function init() {
   RSSFeed::linkToFeed($this->Link() . "rss");	

can anyone help please?
Thanx in advance.


Community Member, 57 Posts

5 August 2009 at 5:46am

Edited: 05/08/2009 5:47am


You need to create a controlled method (in the PortfolioHolderController in this example) to handle this in reverse. Something like:

function ReverseChildren()
         $reversed = $this->Children();
         $reversed->sort('Created', 'DESC');
         return $reversed;

In that code we have created a new DataObjectSet called $reversed and given it the values that 'Children' had (ie, all the child pages). We then sorted it by the field 'Created' descending so the newest is first. You could sort by any field - for instance Title ASC (to get it in alphabetical order of the title).

In the template you need to call that control:

<% control ReverseChildren %>
         <!-- do all your children stuff the same as normal -->
<% end_control %>

I hope this helps,



Community Member, 36 Posts

5 August 2009 at 11:15pm

That worked a charm, thanx so much.