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.

General Questions /

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

how to display link in navigation in two lines


Go to End
Reply


12 Posts   2868 Views

Avatar
anujkryadav

Community Member, 30 Posts

12 December 2009 at 8:17am

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

Avatar
tobych

Community Member, 97 Posts

14 December 2009 at 9:33am

Edited: 14/12/2009 9:34am

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.

Avatar
ulysses

Community Member, 57 Posts

14 December 2009 at 12:29pm

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

Avatar
tobych

Community Member, 97 Posts

14 December 2009 at 12:52pm

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

Avatar
ulysses

Community Member, 57 Posts

14 December 2009 at 12:54pm

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

Avatar
tobych

Community Member, 97 Posts

14 December 2009 at 1:01pm

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

Well, I hope we'll find out.

Avatar
anujkryadav

Community Member, 30 Posts

19 December 2009 at 6:32am

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

Avatar
anujkryadav

Community Member, 30 Posts

19 December 2009 at 6:33am

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

Go to Top