-
Notifications
You must be signed in to change notification settings - Fork 4
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
Overriding templates #23
Comments
I am currently working on a template and component registry in a feature branch, see https://github.com/lukasleitsch/kirby-blade/tree/feature/components-registry The goal is to make it possible for themes to be a regular plugin. The new branch allows you to do the following: Kirby::plugin('my/theme', [
'blade' => [
'namespaces' => [
'mynamespace => 'My\\Theme\\Components', // allows usage of <x-mynamespace::component-name />
],
'templates' => __DIR__ . '/templates',
'components' => [
'demo' => Name\\Space\\SomeComponent::class, // Use class in arbitrary namespace as component
],
],
'snippets => [
'menu' => __DIR__ . '/snippets/menu.blade.php',
],
'templates' => [
'default' => __DIR__ . '/snippets/default.blade.php',
],
]); As you can see, this gives you a ton of options for registering additional templates, snippets etc. The only thing I could not manage to implement are anonymous namespaced components. But apart from that, it already works very stable for a theme that I am currently working on. I decided to build it as a plugin, so updates can be handled through composer or a git submodule. If you want to keep theme files within |
Thank you for the information. Then the overriding will be at plugin level, not possible at directory level. So in order to overwrite a template it will need to be registered via the plugin. Have I got it right? |
If you set |
Kirby::plugin('my/theme', [
'blade' => [
'templates' => __DIR__ . '/templates',
],
]); Ah, now I understand a little more. Considering I set it up like in your example, it will first look in the |
@fabianmichael When do you plan to release the |
@afbora As soon as I find the time for updating the README … don’t know when that will be, sorry. |
Exactly, but currently this only works in the branch mentioned above and still needs documentation! :-)
… Am 24.08.2022 um 13:27 schrieb Ahmet Bora ***@***.***>:
Kirby::plugin('my/theme'
, [
'blade'
=> [
'templates' => __DIR__ . '/templates'
,
],
]);
Ah, now I understand a little more. Considering I set it up like in your example, it will first look in the site/templates directory and then in the path specified in the plugin, right?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
Imagine I'm building a generic theme. But I need to overwrite some templates for a client. So I want it to look in multiple directories. And I want to put the templates I want to be overwritten under
/site/templates
.For example:
Default template for theme path:
/theme/templates/default.blade.php
Override template path:
/site/templates/default.blade.php
Is this possible or is it a feature request?
The text was updated successfully, but these errors were encountered: