Chaitanya Lakshmi
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook

Dynamically changing the Drupal Page Title

2/22/2012

1 Comment

 
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.

Parameters:
$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.

Beware:
$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($node->title);
drupal_set_title(t('Foo !title', array('!title' => $node->title)));

// Correct: 
drupal_set_title(check_plain($node->title)); 
drupal_set_title(t('Foo @title', array('@title' => $node->title)));
1 Comment
Ajay Kumar Gudivada
2/22/2012 09:16:59 pm

What is the difference between "!" and "@" in the examples.

Reply



Leave a Reply.

    Archives

    April 2012
    March 2012
    February 2012

    Categor

    All
    Ajax
    Api
    Cross Site Scripting
    Css
    Curl
    Design Patterns
    Drupal
    Exception Handling
    Htaccess
    Html
    Javascript
    Jquery
    Json
    Linux
    Mysql
    Oops
    Php
    Regular Expressions
    Web 2.0
    Webservices
    Wordpress
    Xhtml

    RSS Feed

Powered by Create your own unique website with customizable templates.