Giter VIP home page Giter VIP logo

titlecomponent's Introduction

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

}

titlecomponent's People

Contributors

enumag avatar rikiless avatar tomaspilar avatar tomasvotruba avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

titlecomponent's Issues

Add trait for cleaner import

From this:

class Presenter ... {

    /** @inject @var Zenify\TitleComponent\IControl */
    public $titleControl;


    public function createComponentTitle()
    {
        return $this->titleControl->create();
    }

}

to this

class Presenter ... {
    use Zenify\TitleComponent\TCreateComponent;

}

Nastavení titulku ze šablony

Není to špatná komponenta, ale má jednu zásadní nevýhodu. Pokud do šablon předávám ve většině případů pouze Nette\Database\Selection nemám možnost v / mětodě titulek nastavit, nemám totiž k dispozici "data". Nešlo by to ješte nějak rozšířit , i když vlastně mohl bych napsat v šabloně $control["kontrola"]->setTitle() .. tak asi jako bych nic nenapsal

Add extension

  • - Allow translation on/off
  • - Allow annotations on/off

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.