This Kirby CMS-Plugin applies custom snippets based on slugs.
- Replaces any snippet for a given slug
- Supports descendant pathes
- Supports multilanguage-setups
- Advantages:
- Control of the frontend output (aka "Art Direction") without content/data-changes in the backend
- Disadvantages:
- In case of slug-changes the snippets must be renamed according the current path
- Kirby 4+
Download and copy this repository to /site/plugins/kirby-alternate-snippets.
git submodule add https://github.com/swiegmann/kirby-alternate-snippets.git site/plugins/kirby-alternate-snippets
composer require swiegmann/kirby-alternate-snippets
You have a snippet-file, e.g. /site/snippets/header.php and want to use a custom snippet for a given slug, e.g. domain.com/some-path/another-path.
Copy the snippet file with one of the following filenames to apply the snippet to
/site/snippets/[snippet-name]--[slug].php
e.g.: /site/snippets/header--news.php.
You can always apply it to deeper slug-pathes:
/site/snippets/[snippet-name]--[slug]--[slug].php
e.g.: /site/snippets/header--news--culture.php.
/site/snippets/[snippet-name]--[slug]--.php
e.g.: site/snippets/header--news--.php.
/site/snippets/[snippet-name]--[slug]--[language-code].php
e.g.: site/snippets/header--news--en.php.
/site/snippets/[snippet-name]--[slug]--[language-code]--.php
e.g.: site/snippets/header--news--en--.php.
Configure global settings in your config.php file:
return [
'swiegmann.kirby-alternate-snippets' => [
'enabled' => true
]
];| Option | Default | Type | Description |
|---|---|---|---|
enabled |
true |
bool | En-/Disable plugin |
MIT License Copyright © 2025-present swiegmann