Jump to:

5541 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » How to Sort Control Menu in Descending order??

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

Page: 1
Go to End
Author Topic: 3402 Views
  • b0bro
    Avatar
    Community Member
    38 Posts

    How to Sort Control Menu in Descending order?? Link to this post

    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

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: How to Sort Control Menu in Descending order?? Link to this post

    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.

  • b0bro
    Avatar
    Community Member
    38 Posts

    Re: How to Sort Control Menu in Descending order?? Link to this post

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

  • Johan
    Avatar
    Community Member
    49 Posts

    Re: How to Sort Control Menu in Descending order?? Link to this post

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

    3402 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.