This plugin extends Kirby’s new snippets with slots and loads layout snippets from site/layouts
This version of the plugin requires Kirby 3.9.0 and helps to migrate from the old layout plugin to our new snippets. We recommend to use native snippets instead.
Download and copy this repository to /site/plugins/layouts
.
git submodule add https://github.com/getkirby/layouts.git site/plugins/layouts
composer require getkirby/layouts
You can create full HTML layouts in a new /site/layouts
folder. Layouts can define slots, which will then be filled with content by templates. Layouts are based on our new snippets with slots and work exactly the same way. The only difference is the folder location. You can learn more about our snippets with slots in our docs: http://getkirby.com/docs/guide/templates/snippets#passing-slots-to-snippets
<html>
<head>
<title><?= $page->title() ?></title>
</head>
<body>
<?= $slot ?>
</body>
</html>
<?php layout() ?>
<h1>Hello world</h1>
<p>This will end up in the default slot</p>
To use a specific layout, you can pass its name to the layout()
method.
<html>
<head>
<title>Blog</title>
</head>
<body>
<h1>Blog</h1>
<?= $slot ?>
</body>
</html>
<?php layout('blog') ?>
<!-- some articles -->
You can add as many different slots to your layout as you need. The default slot goes without a specific name. Every other slot needs a unique name. Slots in layouts can define default content, which will be rendered if the slot is not used in the template.
Read more: http://getkirby.com/docs/guide/templates/snippets#passing-slots-to-snippets
- getkirby.com – Get to know the CMS.
- Try it – Take a test ride with our online demo. Or download one of our kits to get started.
- Documentation – Read the official guide, reference and cookbook recipes.
- Issues – Report bugs and other problems.
- Feedback – You have an idea for Kirby? Share it.
- Forum – Whenever you get stuck, don't hesitate to reach out for questions and support.
- Discord – Hang out and meet the community.
- Mastodon – Spread the word.
- Instagram – Share your creations: #madewithkirby.
MIT