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   3445 Views

Avatar
b0bro

Community Member, 38 Posts

10 August 2009 at 2:19pm

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

Community Member, 712 Posts

10 August 2009 at 5:59pm

Edited: 10/08/2009 6:00pm

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

Community Member, 38 Posts

10 August 2009 at 7:12pm

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

Community Member, 49 Posts

24 August 2010 at 9:41pm

Edited: 24/08/2010 9:45pm

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 %>