swiegmann/kirby-alternate-snippets

This Kirby CMS-Plugin applies custom snippets 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-snippets

1.0.0 2025-11-14 20:38 UTC

This package is auto-updated.

Last update: 2025-11-14 20:48:59 UTC


README

This Kirby CMS-Plugin applies custom snippets based on slugs.

Summary

  • 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

Prerequisites

  • Kirby 4+

Installation

Download

Download and copy this repository to /site/plugins/kirby-alternate-snippets.

Git submodule

git submodule add https://github.com/swiegmann/kirby-alternate-snippets.git site/plugins/kirby-alternate-snippets

Composer

composer require swiegmann/kirby-alternate-snippets

Use-Case

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.

Usage

Copy the snippet file with one of the following filenames to apply the snippet to

... exactly the slug:

/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.

... the slug and all subpages of the path:

/site/snippets/[snippet-name]--[slug]--.php

e.g.: site/snippets/header--news--.php.

... exactly the slug for a specific language:

/site/snippets/[snippet-name]--[slug]--[language-code].php

e.g.: site/snippets/header--news--en.php.

... the slug and all subpages of path for a specific language:

/site/snippets/[snippet-name]--[slug]--[language-code]--.php

e.g.: site/snippets/header--news--en--.php.

Global Configuration

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

License

MIT License Copyright © 2025-present swiegmann