1

Most of the content-nodes on my site have two parts (English | Arabic). I want to put a line break between the two, so that the broken text does not look awkward. But when I put an html line-break tag, the tag itself shows up in the title.

What to do?

Appreciated...

4 Answers 4

3

As I understand you want have your nodes titled using pattern <English name><Arabic name>, and split your title on 'language border' to different lines. As was mentioned node title is used in both places content title, and page title.

So you can use changed pattern <English name>|<Arabic name> and override your template file in your theme. You can use str_replace before displaying title for your node. Also your page title will look ok, without changing theme more; and this solution support titles without | delimiter, or with more then 1.

2
  • Nice suggestion. Right now I am adding the content to the default theme, once I choose a better theme later, I will give this a shot.
    – AKR
    Commented Sep 1, 2011 at 13:54
  • You can quite easily keep using the default theme (Bartik, I guess?), and override some elements of it. To do that, create a Bartik subtheme for your customizations. Commented Oct 6, 2011 at 7:25
0

HTML tags are not allowed in titles, and they are escaped. The HTML 4.01 Specification reports the following text:

Titles may contain character entities (for accented characters, special characters, etc.), but may not contain other markup (including comments). Here is a sample document title:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>A study of population dynamics</TITLE>
... other head elements...
</HEAD>
<BODY>
... document body...
</BODY>
</HTML> 

For using HTML tags in the page title, you should set it with drupal_set_title($title, PASS_THROUGH), but I would not suggest doing it, as the title is used for both the page, and the browser title, which should not contains HTML tags for what I reported before.
As PASS_THROUGH by-pass the call to check_plain(), you should check the value you pass as $title, and verify it doesn't contain dangerous characters. I would also suggest to use the Page Title module to avoid the browser title contains any HTML tags; as the module set for the browser title a value different from the page title, you could have HTML tags only in the page title.

Apart from separating the text with " | " the only solution is to have the title in a single language; after all Drupal support multi-language content, and the translation of a node to different enabled languages.

2
  • I apologize, I did not make it clear. I am talking about the Content Title of the node, not the Page-Title.
    – AKR
    Commented Aug 30, 2011 at 22:58
  • I expanded my answer.
    – avpaderno
    Commented Aug 30, 2011 at 23:36
0

It is not possible, at least not directly. Some thoughts:

  1. Use Drupal multilingual tools to store multiple-language-versions of node content including titles.
  2. Use the Page Title module to generate custom <title> tags from CCK fields, tokens, etc.
  3. Use a custom field using an input filter that allows HTML to store this "title", theme your content type to display this field instead of the default title field.

Node title is plain text only and will likely remain that way.

2
  • Thanks, lot of steps to take to break a line. But I'm sure there must be some good reason to keep these content-node titles as plain text. Alright, I think a few broken titles won't bother much.
    – AKR
    Commented Aug 30, 2011 at 23:02
  • These are separate suggestions and not steps I think.
    – Berdir
    Commented Oct 6, 2011 at 7:01
0

Why not use CCK to add a new Arabic title field to the content type(s) and place it immediately after the default title? After that it's just a matter of CSS to position it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.