4.6.x bootstrap.inc drupal_set_title($title = NULL)
4.7.x path.inc drupal_set_title($title = NULL)
5.x path.inc drupal_set_title($title = NULL)
6.x path.inc drupal_set_title($title = NULL)
7.x bootstrap.inc drupal_set_title($title = NULL, $output = CHECK_PLAIN)

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.

58 calls to drupal_set_title()
aggregator_page_source in modules/aggregator/aggregator.pages.inc
Menu callback; displays all the items captured from a particular feed.
block_admin_configure in modules/block/block.admin.inc
Menu callback; displays the block configuration form.
blog_page_user in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of a given user.
book_admin_edit in modules/book/book.admin.inc
Build the form to administrate the hierarchy of a single book.
book_outline in modules/book/book.pages.inc
Menu callback; show the outline form for a single node.

... See full list

File

includes/path.inc, line 206
Functions to handle paths in Drupal, including path aliasing.

Code

function drupal_set_title($title = NULL) {
  static $stored_title;

  if (isset($title)) {
    $stored_title = $title;
  }
  return $stored_title;
}

Comments

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

If you have user supplied HTML that must be passed to drupal_set_title, filter it so it contains only harmless tags:

// Incorrect:
drupal_set_title($user_supplied_html);

// Correct:
drupal_set_title(filter_xss($user_supplied_html));

I want to provide social share with link to most popular bookmarking site, for the purpose of performance improvement I don't link to use any social share/link modules instead I want to used only one image and linking it with various social sites using html image map tag and link code similar to the below one.

Twitter: http://twitter.com/home?status=[TITLE]+[URL]

Facebook: http://www.facebook.com/share.php?u=[URL]&title=[TITLE]

StumbleUpon: http://www.stumbleupon.com/submit?url=[URL]&title=[TITLE]

Delicious: http://del.icio.us/post?url=[URL]&title=[TITLE]]&notes=[DESCRIPTION]

Google Buzz: http://www.google.com/reader/link?title=[TITLE]&url=[URL]

Linkedin: http://www.linkedin.com/shareArticle?mini=true&url=[URL]&title=[TITLE]&s...

But I am not know how to get drupal current node url and node title and what to replace [URL] and [TITLE] in the above said social share link urls.

I tried to place the above code in page.tpl.php by replacing [URL] with $url and [TITLE] with $title and that is not useful to fetch the actual url and title from the node.

I thank you for your valuable helps in this regard.

Have you tried :

print $node->title; // node title
print url($node_url, array('absolute' => TRUE)); // for url

However, you should put this in node.tpl.php because page.tpl.php may contain many nodes in some cases.

T.

when i use the drupal_set_title to set the title to "123 abc" it sets the title as: "123 abc | Site Name" is there any way to avoid this?

check out page.tpl.php in your theme -- in the title attribute you're probably also printing the site name.

or you might be using $head_title -- which also has the site name in it. check out this thread: http://drupal.org/node/77522