Via Composer:
$ composer require zenify/title-component
Register extension in config.neon
:
extensions:
- Zenify\TitleComponent\DI\TitleExtension
Inject to presenter
class Presenter ...
{
/**
* @inject
* @var Zenify\TitleComponent\TitleControlFactory
*/
public $titleControlFactory;
/**
* @return Zenify\TitleComponent\TitleControl
*/
protected function createComponentTitle()
{
return $this->titleControlFactory->create();
}
}
Render in template
<head>
...
{control title}
</head>
Via annotation
class HomepagePresenter ...
{
/**
* @title Contact us
*/
public function renderContact()
{
}
}
Or via method
class ProductPresenter ...
{
public function startup()
{
// set main title for whole app
$this['title']->set('Zenify');
parent::startup();
}
/**
* @param int
*/
public function renderDetail($id)
{
$product = ...($id);
$this['title']->append('Detail of ' . $product->name);
// change separator if you like
$this['title']->setSeparator(' - ');
}
}
This will result in:
Zenify - Detail of product ...
class HomepagePresenter ...
{
/**
* @title homepage.contact.title
*/
public function renderContact()
{
}
/**
* @param string
*/
public function renderDetail($name)
{
$this['title']->set(['user.detail.name', NULL, ['name' => $name]]);
}
}