Componette

Componette

deprecated-packages

deprecated-packages / TitleComponent 5.0.3

[DEPRECATED] Title component for Nette

download-cloud-line composer require zenify/title-component

Title Component

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

}
  • 5.0.3

  • v5.0.2 Released version v5.0.2

  • v3.0.0 Released version 3

    • removed prefix for ControlFactory [BC break]
    • for other changes see diff v2.1.0...v3.0.0
  • v2.1.0 Released version 2.1

    • PHP 5.3 support added
    • trait approach added
    • new methods append(), prepend()
    • tests added
    • BC break: setBrand() removed
  • v1.1 Released version 1.1

    • brand support added, see readme
Componette Componette felix@nette.org