swiegmann / kirby-alternate-templates
This Kirby CMS-Plugin applies custom templates based on slugs.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:kirby-plugin
pkg:composer/swiegmann/kirby-alternate-templates
Requires
- php: >=8.1.0 <8.4.0
- getkirby/cms: ^4.0
- getkirby/composer-installer: ^1.2
README
This Kirby CMS-Plugin applies custom templates based on slugs.
Summary
- Replaces any template for a given slug
- Supports descendant pathes
- Supports multilanguage-setups
- Advantages:
- Affected pages still use the same blueprint, but you have control of the frontend output (aka "Art Direction") without content/data-changes in the backend
- Disadvantages:
- In case of slug-changes the templates must be renamed according the current path
- Disclaimer: This plugin extends the core-class
Templateand may conflict with other plugins that do so
Prerequisites
- Kirby 4+
Installation
Download
Download and copy this repository to /site/plugins/kirby-alternate-templates.
Git submodule
git submodule add https://github.com/swiegmann/kirby-alternate-templates.git site/plugins/kirby-alternate-templates
Composer
composer require swiegmann/kirby-alternate-templates
Use-Case
You have a template-file, e.g. /site/templates/category.php and want to apply a custom template for a given slug, e.g. domain.com/some-path/my-special-category - but still keeping the same blueprint for the records.
Usage
Create a new template file with one of the following filenames to apply the template to
... exactly the slug:
/site/templates/[template-name]--[slug].php
e.g.: /site/templates/category--news.php.
You can always apply it to deeper slug-pathes:
/site/templates/[template-name]--[slug]--[slug].php
e.g.: /site/templates/category--news--culture.php.
... the slug and all subpages of the same blueprint:
/site/templates/[template-name]--[slug]--.php
e.g.: site/templates/category--news--.php.
... exactly the slug for a specific language:
/site/templates/[template-name]--[slug]--[language-code].php
e.g.: site/templates/category--news--en.php.
... the slug and all subpages of the same blueprint for a specific language:
/site/templates/[template-name]--[slug]--[language-code]--.php
e.g.: site/templates/category--news--en--.php.
Global Configuration
Configure global settings in your config.php file:
return [ 'swiegmann.kirby-alternate-templates' => [ 'enabled' => true ] ];
| Option | Default | Type | Description |
|---|---|---|---|
enabled |
true |
bool | En-/Disable plugin |
License
MIT License Copyright © 2025-present swiegmann