Hi,
I am trying to pass some variables into my theme. I have setup my theme class file like follows:
<?php
namespace Grav\Theme;
use Grav\Common\Theme;
class MyTheme extends Theme
{
public static function getSubscribedEvents()
{
return [
'onThemeInitialized' => ['onThemeInitialized', 0]
];
}
public function onThemeInitialized()
{
if ($this->isAdmin()) {
$this->active = false;
return;
}
$this->enable([
'onTwigSiteVariables' => ['onTwigSiteVariables', 0]
]);
}
public function onTwigSiteVariables()
{
$this->grav['twig']->myVariable = 'test';
}
}
I would like to be able to access the variable myVariable
within my theme’s header.
{{ myVariable }}
doesn’t seem to work. What am I doing wrong?
Thanks,