zenify / title-component
Title component for Nette
Installs: 10 445
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 3
Open Issues: 0
Requires
- php: >=5.5
- nette/application: ~2.2
- tracy/tracy: ~2.2
Requires (Dev)
- nette/bootstrap: ~2.2
- nette/robot-loader: ~2.2
README
Install
Via Composer:
$ composer require zenify/title-component
Register extension in config.neon
:
extensions: - Zenify\TitleComponent\DI\TitleExtension
Usage
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>
Add title
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 ...
Translator supported
class HomepagePresenter ... { /** * @title homepage.contact.title */ public function renderContact() { } /** * @param string */ public function renderDetail($name) { $this['title']->set(['user.detail.name', NULL, ['name' => $name]]); } }