Theme Inheritance Breaks Down If The Parent Needs A Custom Plugin #154
Closed
Description
In the case of the Materialize theme, the Materializer plugin is needed for functionality. I accomplished that with code in materialize.php
:
<?php
namespace Grav\Theme;
use Grav\Common\Theme;
class Materialize extends Theme
{
// Materializer plugin will look for this class var to know it should load
public $load_materializer_plugin = true;
public static function getSubscribedEvents()
{
return [
'onThemeInitialized' => ['onThemeInitialized', 0]
];
}
public function onThemeInitialized()
{
if ($this->isAdmin()) {
$this->active = false;
return;
}
$this->enable([
'onPageInitialized' => ['onPageInitialized', 0]
]);
}
public function onPageInitialized()
{
$this->config->set('plugins.pagination.built_in_css', false);
$this->config->set('plugins.relatedpages.show_score', false);
}
}
Child themes don't inherit this code, so don't handle plugins properly.
A workaround is to replicate the parent theme's .php
file functions in the child theme's .php
file.