Jump to:

23460 Posts in 18907 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » how to display link in navigation in two lines

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2
Go to End
Author Topic: 2803 Views
  • anujkryadav
    Avatar
    Community Member
    30 Posts

    how to display link in navigation in two lines Link to this post

    I have creating a website where few of my link in navigation have two or more words.I want to break the link in navigation into two lines.I am having a two layer drop down menu .Please help me out.My link are

    -home
    -about Us
    --Student
    --managment
    -Branch
    --Local Branch
    --International Branch
    -Student & managment Speeches

    For example I want to break Student & managment Speeches to be appeared as
    Student &
    managment Speeches

    in the navigation.
    Thank you in advance

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: how to display link in navigation in two lines Link to this post

    You'll need to use some custom PHP to break that line up.

    I suggest you aim at getting something like this working:

    class Page extends SiteTree {

    ...

    public function getMenuTitleWithNewlines() {
    return $this->addNewlines($this->obj('MenuTitle')->XML());
    }

    function addNewlines($title) {
    return /* $title with &amp; replaced by <br> */;
    }

    }

    Then in your template, use $MenuTitleWithNewlines instead of $MenuTitle.

  • ulysses
    Avatar
    Community Member
    57 Posts

    Re: how to display link in navigation in two lines Link to this post

    Alternatively you can break up the top level menu page to be just SPEECHES and then the child pages to be Student & Management

    So it will look like this:

    |-Home
    |-+About Us
    |--Student
    |--Management
    |-+Branch
    |--Local Branch
    |--International Branch
    |-+Speeches
    |--Student
    |--Management

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: how to display link in navigation in two lines Link to this post

    An infinitely better way to go, assuming there's no reason why it isn't better.

  • ulysses
    Avatar
    Community Member
    57 Posts

    Re: how to display link in navigation in two lines Link to this post

    My suggestion is based on the KISS principle. Why create complicated logic, if you can re-organise the data.

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: how to display link in navigation in two lines Link to this post

    Indeed. I was assuming the poster had his reasons. But it did seem unlikely.

    Well, I hope we'll find out.

  • anujkryadav
    Avatar
    Community Member
    30 Posts

    Re: how to display link in navigation in two lines Link to this post

    Thank you for the reply
    but i cant change the link structure,its a client requirement and he wants that way

  • anujkryadav
    Avatar
    Community Member
    30 Posts

    Re: how to display link in navigation in two lines Link to this post

    hello tobych
    thanks for your reply,it is working great,

    2803 Views
Page: 1 2
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.