Add the possibility to attach template hooks with a callback

This commit is contained in:
Frederic Guillot
2016-08-13 18:41:01 -04:00
parent 2ebe8b3272
commit 010199e8f8
4 changed files with 87 additions and 1 deletions

View File

@@ -161,6 +161,14 @@ $this->template->hook->attach('template:dashboard:sidebar', 'myplugin:dashboard/
));
```
Example to attach a template with a callable:
```php
$this->template->hook->attach('template:dashboard:sidebar', 'myplugin:dashboard/sidebar', function($hook_param1, $hook_param2) {
return array('new_template_variable' => 'foobar'); // Inject a new variable into the plugin template
});
```
This call is usually defined in the `initialize()` method.
The first argument is name of the hook and the second argument is the template name.