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.
Adding Line Breaks in Menu Text [solved]
Re: Adding Line Breaks in Menu Text [solved]
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_':'
'}.
'}.
In your menu template change every occurrence of {$node->menutext} to {$node->menutext|replace:'_br_':'
'}.
Re: Adding Line Breaks in Menu Text [solved]
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]
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.
-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.
-
- Power Poster
- Posts: 300
- Joined: Tue Mar 04, 2008 10:37 am
Re: Adding Line Breaks in Menu Text [solved]
Could come in handy in some cases I reckonDidiero 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.

Re: Adding Line Breaks in Menu Text [solved]
This trick can also be used in the title as is described here.