zenify/title-component

This package is abandoned and no longer maintained. No replacement package was suggested.

Title component for Nette

5.0.3 2019-01-08 07:18 UTC

This package is auto-updated.

Last update: 2022-01-27 10:58:37 UTC


README

Build Status Quality Score Code Coverage Downloads this Month Latest stable

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]]);
	}

}