Tuesday, 3 July 2012

Dynamically changing the Drupal Page Title

drupal_set_title (path.inc)
drupal_set_title($title = NULL)Set the title of the current page, for display on the page and in the title bar.

$title Optional string value to assign to the page title; or if set to NULL (default), leaves the current title unchanged.

Return value The updated title of the current page.

$title is interpreted as HTML. If you have plaintext strings such as for example $node->title, you must escape them with check_plain or use the correct placeholder in t() before passing them to drupal_set_title(). If you don't, users can execute a cross site scripting attack against your site.

// Incorrect: 
drupal_set_title(t('Foo !title', array('!title' => $node->title)));

// Correct:
drupal_set_title(t('Foo @title', array('@title' => $node->title)));

No comments:

Post a Comment

Thank you so much for providing your valuable feedback. I will will look into them and update my skills & technologies accordingly.