Skip to content

swiegmann/kirby-alternate-snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kirby Alternate Snippets

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages