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

12 Posts   2849 Views


12 December 2009 at 8:17am Community Member, 30 Posts

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

-about Us
--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


14 December 2009 at 9:33am (Last edited: 14 December 2009 9:34am), Community Member, 97 Posts

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.


14 December 2009 at 12:29pm Community Member, 57 Posts

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:

|-+About Us
|--Local Branch
|--International Branch


14 December 2009 at 12:52pm Community Member, 97 Posts

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


14 December 2009 at 12:54pm Community Member, 57 Posts

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


14 December 2009 at 1:01pm Community Member, 97 Posts

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

Well, I hope we'll find out.


19 December 2009 at 6:32am Community Member, 30 Posts

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


19 December 2009 at 6:33am Community Member, 30 Posts

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

Go to Top