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

1.0.0 2025-11-14 20:43 UTC

This package is auto-updated.

Last update: 2025-11-14 20:50:45 UTC


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 Template and 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