# drResponseTitlePlugin #
The ``drResponseTitlePlugin`` takes care of the response title and provides methods for
adding parts to the response title from several places in your application. This way you
can combine several title parts into one title, separated by for example a dash:
Site name - News - New plugin released
By default the plugin reverses the order of the title parts, which is better with SEO in mind:
New plugin released - News - Site name
## Installation ##
Open the file ``/config/ProjectConfiguration.class.php`` and enable the plugin:
[php]
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins(array(
...
'drResponseTitlePlugin',
));
}
}
## Usage ##
When enabled, the plugin provides a title holder for the response. From several places you can
add parts to the response title or reset it.
In your actions, add title parts to the title holder:
[php]
class newsActions extends sfActions
{
public function preExecute()
{
$this->getResponse()->getTitleHolder()->addTitlePart('News');
}
public function executeShow(sfWebRequest $request)
{
$this->news = $this->getRoute()->getObject();
$title_part = $this->news->getTitle();
$this->getResponse()->getTitleHolder()->addTitlePart(title_part);
}
}
In your layout, call the helper function to render the ``<title>`` tag and it's contents (place this call inside the ``<head>`` tag):
[php]
include_composed_title();
The helper function also excepts a number of (optional) parameters, to separate title parts by a specific string
[php]
include_composed_title(' | ');
To render the title parts in reverse order:
[php]
include_composed_title(' | ', true);
To also include or exclude the existing response title, set the third argument to ``true`` or ``false`` respectively:
[php]
include_composed_title(' | ', true, true);
## Configuration ##
You may change the default separator (' - ') in advance:
[php]
sfContext::getInstance()->getResponse()->getTitleHolder()->setSeparator(' | ');
Or you may set the render order to normal (instead of reverse):
[php]
sfContext::getInstance()->getResponse()->getTitleHolder()->setReverse(false);