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.

Customising the CMS

How to Sort Control Menu in Descending order??


Reply

4 Posts   3432 Views

Avatar
b0bro

10 August 2009 at 2:19pm Community Member, 38 Posts

Hi,

My navigation is float right! So My homepage link is appearing last if you read it normally from left to right.

Of course i can re-order my pages in the CMS so the home page is on the bottom. But this is a dirty fix. Im sure there is a way i can sort the Control Menu in reverse or desc order??

I just cant find it, please can some one point me in the right direction.

Byron

Avatar
Hamish

10 August 2009 at 5:59pm (Last edited: 10 August 2009 6:00pm), Community Member, 712 Posts

My navigation is float right!

ZOMG!

Im sure there is a way i can sort the Control Menu in reverse or desc order??

This is a CSS issue rather than a problem with SilverStripe. Rather than floating the list elements ('li') to the right, you should float containing element right, with the child elements floating left within it. The actual order of the list elements should not need to change.

Avatar
b0bro

10 August 2009 at 7:12pm Community Member, 38 Posts

Okay, that does work and is one solution i over looked, thank you!

However, i still wish to know if it is possible to sort in a desc order??

Avatar
Johan

24 August 2010 at 9:41pm (Last edited: 24 August 2010 9:45pm), Community Member, 49 Posts

This is a CSS issue rather than a problem with SilverStripe. Rather than floating the list elements ('li') to the right, you should float containing element right, with the child elements floating left within it. The actual order of the list elements should not need to change.

This is sadly not going to work for me. The problem with the CSS fix above is:

1. If the menu item is removed there is gap to the right unless the width of the menu container is changed via CSS!
2. No more menu items can be added unless the width of the menu container is changed!

The code for this is:

   public function sortedChildren() {
      $children = $this->Menu(1);
      $children->Sort('Sort', 'DESC');
      return $children;
   }

// usage in template: <% control sortedChildren %>