Page 1 of 1

Adding Line Breaks in Menu Text [solved]

Posted: Wed Dec 19, 2007 9:22 pm
by raindogmx
I posted this solution to a very old thread so I'm posting here again.

Someone asked about how to insert line breaks (and other HTML tags) into menu texts. The problem is that when you put a tag into the menu text for example "My menu
item" then the tag will appear literally on the page.

I used this with success in a menu template:

{$node->menutext|replace: '_br_' : '
'}

It means the menu text should have '_br_' where you want the line breaks to appear. That will tell smarty to replace _br_ with an actual line break tag.

Re: Adding Line Breaks in Menu Text [solved]

Posted: Tue Aug 26, 2008 2:03 pm
by Didiero
Thank you for this solution. I am a newbie and needed some time to get this to work. The problem were the blanks after the first colon and around the second colon. They produced a Smarty error. This might be obvious for a programmer, but maybe not for a designer. Here is the correct string without the blanks: {$node->menutext|replace:'_br_':'
'}.

In your menu template change every occurrence of {$node->menutext} to {$node->menutext|replace:'_br_':'
'}.

Re: Adding Line Breaks in Menu Text [solved]

Posted: Wed Aug 27, 2008 3:42 am
by Dr.CSS
May I ask what these are for, won't it put a break after the menu text?...

Re: Adding Line Breaks in Menu Text [solved]

Posted: Wed Aug 27, 2008 7:12 am
by Didiero
It replaces the string "_br_" in the menutext field in the backend with a
-Tag in the frontend. If a longer menutext needs two or more lines in a vertical menu you can tell it where the line breaks should be using this method.

Re: Adding Line Breaks in Menu Text [solved]

Posted: Wed Aug 27, 2008 9:56 am
by christiaans
Didiero wrote: It replaces the string "_br_" in the menutext field in the backend with a
-Tag in the frontend. If a longer menutext needs two or more lines in a vertical menu you can tell it where the line breaks should be using this method.
Could come in handy in some cases I reckon :).

Re: Adding Line Breaks in Menu Text [solved]

Posted: Wed Aug 27, 2008 10:32 am
by Didiero
This trick can also be used in the title as is described here.