title line break

trevornz - November 7, 2006 - 01:18

Hi There

Does any one know how to create a line break in a Drupal title? To force the title over two lines.

I've tried
with no joy. Is it possible?

me too

MikeyLikesIt - February 28, 2007 - 23:22

I'd also love to know if there is a method for doing this. Many of the articles I publish are multi-part, and it would be great to have a way to break them up.

Very Hackish Suggestion

mmaul - July 7, 2007 - 14:36

I’m trying to do the same at the moment. From a semantic point of view, this is problematic IMO because adding line break information to text rendered inside a header tag would mean adding display markup at the wrong place.

Anyway, one of my customers is asking for it, and he probably won’t buy the semantic argument. ;-) So my first and admittedly hacky route would be to add some unobtrusive character (maybe ‘•’ or ‘·’ ) in the title text at the place where the line break is intended and convert this to a <br/> when the title is rendered. Putting a <br/> in the title text will produce strange results for those using RSS readers, so an inconspicuous, yet easily insertable character would probably be best suited.

I’m going to implement this in one of my local modules and report back here, but I guess you shouldn’t expect this to become mainstream, as one shouldn’t insert display markup where it doesn’t belong. Additionally, a forced layout will break when users change display text size.

Cheers,
Mathias

Even more hackerish solution

KenleyT - December 29, 2007 - 02:48

Hey,

mmaul, that's a lot of work. ;-) You can just go to MS Word's symbol table and "Special Characters" and use those blank em spaces there. The blank spaces is treated differently from the space bar's space and can push your titles to the next line. Hope this helps.

Thanks,
Ken

em space

stackpool - September 30, 2008 - 00:18

I tried this. It seemed to work in the preview, but then it turned into a question mark when I saved, and then I got a fatal error in includes/common.inc (Unsupported operand types) and now can't get back to the page to edit out the em space.

So, maybe back to the drawing board with this one...

Thanks anyway!

Nearly there

mmaul - August 26, 2009 - 08:38

Ken,

this wouldn’t have worked with this specific client. He couldn’t even find the “|” character, so he wouldn’t have been able to find, insert and remember any special whitecase characters …

Mathias

Golfing drupallers are invited to listen to my mental golf coaching podcast at http://www.headprocoaching.com/podcast/

Eerie … two years later, I

mmaul - August 26, 2009 - 08:36

Eerie … two years later, I find my own post after doing a Google search for the same issue. ;-)

(BTW, I *did* manage to convince the client, so I didn’t implement the proposed solution.)

Golfing drupallers are invited to listen to my mental golf coaching podcast at http://www.headprocoaching.com/podcast/

I solved this by adding a

WorldFallz - September 30, 2008 - 18:25

I solved this by adding a subtitle field and some theming in node.tpl.php and page.tpl.php.

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

Use CSS

wnwek - December 27, 2008 - 06:12

I used CSS to break up my title over two parts. I used the "width" tag and made it progressively smaller till the title broke over two parts.

http://drupal.org/node/28537

keva - July 8, 2009 - 17:51

I used the instructions here: http://drupal.org/node/28537

but added a break also, so my template.php looks like this:

/* Inserting HTML into node titles
* http://drupal.org/node/28537
*/

function bb2html($text) {
  $bbcode = array(
                  "[strong]", "[/strong]",
                  "[b]",  "[/b]",
                  "[i]",  "[/i]",
                  "[br]",
                  "[em]", "[/em]"
                );
  $htmlcode = array(
                "<strong>", "</strong>",
                "<strong>", "</strong>",
                "<em>", "</em>",
                "<br />",
                "<em>", "</em>"
              );
  return str_replace($bbcode, $htmlcode, $text);
}

function bb_strip($text) {
  $bbcode = array(
                  "[strong]", "[/strong]",
                  "[b]",  "[/b]",
                  "[i]",  "[/i]",
                  "[br]",
                  "[em]", "[/em]"
                );
  return str_replace($bbcode, '', $text);
}

 
 

Drupal is a registered trademark of Dries Buytaert.