-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inherited theme : make it possible to customize specific blocks from base.html.twig #95
Comments
I've stumbled over the same problem. What I did to solve this problem cleanly is to explicitly add Quark as a twig namespace by using the theme's My "my-theme" is set up using the devtools and inherits from the Quark theme. The contents of <?php
namespace Grav\Theme;
use Grav\Common\Grav;
use Grav\Common\Theme;
class MyTheme extends Quark {
public static function getSubscribedEvents() {
return [
'onTwigLoader' => ['onTwigLoader', 10]
];
}
public function onTwigLoader() {
parent::onTwigLoader();
// add quark theme as namespace to twig
$quark_path = Grav::instance()['locator']->findResource('themes://quark');
$this->grav['twig']->addPath($quark_path . DIRECTORY_SEPARATOR . 'templates', 'quark');
}
} And when I want to overwrite a block in {% extends '@quark/partials/base.html.twig' %}
{% block header %}
This is a shitty header now.
{% endblock %} Quite a pleasure to be able to modify Gravs behavior so easily, major props to the developers. |
Just ran into the same issue. Thanks @luuuke |
@luuuke 's solution is elegant. I recommend this approach! |
This might be added to documentation. Maybe to cookbook section somewhere? |
The docs are fully open to user submissions of this type. I would gladly accept a PR that provided this approach. |
@rhukster i understand your position, but i don't feel like -- at this point -- closing this ticket was the right action. indeed, one way to solve this ticket is to accept a PR that adds the snippet above to the docs. please, consider reopening this ticket. |
Here you go :) |
thanks @Karmalakas ! |
When building a theme that inherits Quark, I think there's no clean way to customise a specific block of the base template.
This is also an issue with Antimatter.
Somebody opened a ticket for Antimatter:
getgrav/grav-theme-antimatter#97
and even made a pull request:
getgrav/grav-theme-antimatter#100
which has been left uncommented.
Please, refer to the original ticket for the reasons behind this request.
The text was updated successfully, but these errors were encountered: