rocketmedia-cz / flashmessages
Visual component for displaying FlashMessages
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:addon
Requires
- php: >=5.4.0
- nette/nette: ~2.1.0
This package is not auto-updated.
Last update: 2024-12-21 17:32:56 UTC
README
This simple visual addon help to display and translate flash messages.
Requirements
- PHP 5.4.0 or higher
- Nette Framework 2.1
Installation
The best way is by Composer:
$ composer require rocketmedia-cz/flashmessages:dev-master
Or you can simple download package and place it to vendor/others folder.
and you must enable addon through your cofing.neon, just put these lines into it
services:
flashmessages:
implement: Scribe\Addons\FlashMessages\IFlashMessagesControlFactory
parameters: [templateFile, translator]
arguments: [%templateFile%, %translator%]
or if you won't change template file or use translator with magic function throught interface, you can use shorted version
services:
flashmessages: Scribe\Addons\FlashMessages\IFlashMessagesControlFactory
Setup
In presenter we can use @inject annotation from Nette version 2.1 -
/** @var \Scribe\Addons\FlashMessages\IFlashMessagesControlFactory @inject */ public $flashMessagesControl; /** * @return \Scribe\Addons\FlashMessages\FlashMessagesControl */ protected function createComponentFlashMessages() { return $this->flashMessagesControl->create(); }
If we want to change template file or translate our messages, we have to change parameters in create() function.
return $this->flashMessagesControl->create('newTemplateFile.latte', $ourTranslator);
Usage
Just initialize component in template and it is.
{control flashMessages}
Default template is in snippet, so you can redraw snippet with flash messages
$this->redrawControl('flashMessages');
Created by David Zadražil for Rocketmedia.cz.