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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Connect With Other SilverStripe Members /

For all SilverStripe-related topics that don't fit into any of the categories above.

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

breaking menu title into two lines


Go to End


1965 Views

Avatar
Rishi

Community Member, 97 Posts

4 February 2010 at 7:12am

Edited: 04/02/2010 7:13am

hello
i have menu link which i want to break into two lines after come i,e in my menu i have page with tile as teachers,& student and i want to break this title into two lines after coma i e
teachers
&student

i gota code and i have tried it but after inserting the code all my menu has disaapered.the code is

in page.ss
i have written a function as

class Page_Controller extends ContentController {

public function init() {
parent::init();

// Note: you should use SS template require tags inside your templates
// instead of putting Requirements calls here. However these are
// included so that our older themes still work
Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");
}
///MY FUNCTION

function MultiLineTitle($delimiter = ",") {
$title = explode($delimiter, $this->MenuTitle);
foreach($title as $key => $value)
$title[$key] = Convert::raw2xml($value);
return implode("<br />", $title);
}
}

and in navigation.ss
<ul>
<% control Menu(1) %>
<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MultiLineTitle.XML</span></a></li>
<% end_control %>
</ul>

//have changed $MenuTitle.XML to $MultiLineTitle.XML

thanks you in advnace