Add Static Text In Title Of Page

From Joomla! Documentation

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Add a static text in the <title>[edit]

A common requirement is to customise the way in which the page title is displayed, For example, including the site name as part of the page title. The code on this page will allow you to change the global page title across the entire site. You may customise it to your own liking within your own template files. The code can be placed anywhere in your template index.php, although most people tend to insert it near the top or within the <head> element.

To get the current page title:

<?php
$title = $this->getTitle();
?>

Similarly, you use setTitle to set a new page title. For example, to append the site name to the regular page title, you can use code like this:

<?php
$app = JFactory::getApplication();
$this->setTitle( $title . ' - ' . $app->getCfg( 'sitename' ) );
?>

Combining these two pieces of code together, you can do this:

<?php
$app = JFactory::getApplication();
$this->setTitle( $this->getTitle() . ' - ' . $app->getCfg( 'sitename' ) );
?>

Here's a more complete example of what a template would look like with this code embedded in it:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
$app = JFactory::getApplication();
$this->setTitle( $this->getTitle() . ' - ' . $app->getCfg( 'sitename' ) );
?>
<jdoc:include type="head" />

.... rest of template file.

Add Heading Tags in the Titles for More Relevance[edit]

Search engines give a special relevance to the sentences between a "H" tag like <h1>, <h2> or <h3>.

I you want put a "H" tag to joomla 1.5 you need edit some files:

Override components/com_content/views/category/tmpl/blog.php

search for this piece of code (Line 5):

<div class="componentheading<?php echo $this->params->get('pageclass_sfx');?>">
  <?php echo $this->escape($this->params->get('page_title')); ?>
</div>

add your "H" tags between the title like this:

<div class="componentheading<?php echo $this->params->get('pageclass_sfx');?>">
   <h1><?php echo $this->escape($this->params->get('page_title')); ?></h1>
</div>

If you add more "H" tags between the joomla titles search into the tmpl directories for the code:

get('page_title')

And add the "H" tags.

Remember to normalize the font-size of the "H" tags using CSS. For example, edit your template css and add something like:

.componentheading h1 {
font-size: 16px;
}

To override the output of a component or module see: How to override the output from the Joomla! core