Muut
November 24, 2014, 9:38pm
1
Docs say that we can use plugin events, are all available just as they would be for plugins?
Reason for it would be to override a setting that’s in mytheme.yaml. Is there a better way of doing it besides if (!isset(page.header.width )) page.header.width = $this->config->get(‘width’)
Muut
November 24, 2014, 9:46pm
2
Yes you can use all plugin events in your theme’s PHP file. They are like a special-case plugin.
Muut
November 24, 2014, 9:44pm
3
That is awesome, and I’d be able to set ‘form’ options in YAML to have those options show in Admin when that time comes?
Muut
November 24, 2014, 9:48pm
4
Yes, those will go in the blueprints.yaml
. Any form items you define there will automatically show up in the admin.
Muut
November 24, 2014, 9:47pm
5
That is awesome. I was working with Phile CMS which is very similar to Grav and I had to use a separate plugin to make it all work that way.
What would be the best way to have a page header override a setting set in mytheme.yaml?
Muut
November 24, 2014, 10:06pm
6
Take a look at the SmartyPants plugin, here’s a code snippet:
$defaults = (array) $this->config->get('plugins.smartypants');
$page = $event['page'];
if (isset($page->header()->smartypants)) {
$this->config->set('plugins.smartypants', array_merge($defaults, $page->header()->smartypants));
}
Basically does an array_merge to merge the page headers with the default configuration.
Muut
November 25, 2014, 7:48am
7
All events will work except for onPluginsInitialized. Instead of that you can use onThemeInitialized.