Skip to content

Layout snippets do not work from within other layout snippets #7567

@JojOatXGME

Description

@JojOatXGME

Description

When I use a layout snippet within another layout snipped, the content is discarded without any error reported.

Expected behavior

I would expect to see the content of the included snippet.

Note

Since I found a workaround, the issue is not really important to me. However, I was a bit lost initially when I got an empty page without any error. I thought I should let you know anyway.

To reproduce

  1. Create a snippet
  2. Create another snippet which uses the previous snipped as a layout snippet
  3. Create a template which uses the snipped from step 2 as a layout snippet
  4. Content of the snipped from step 1 is missing

Example

In the following example, I get a HTTP 200 response, but the page is completely empty.

JojOatXGME/plainkit@5798fca

Alternative: patch on top of plainkit (based on commit 3d651f772485fa7ec836238bde103d4368e9fdcb)
$ git diff --staged
diff --git a/site/snippets/base.php b/site/snippets/base.php
new file mode 100644
index 0000000..74e38ae
--- /dev/null
+++ b/site/snippets/base.php
@@ -0,0 +1 @@
+<h1><?= $page->title() ?></h1>
diff --git a/site/snippets/subsnippet.php b/site/snippets/subsnippet.php
new file mode 100644
index 0000000..b95c82b
--- /dev/null
+++ b/site/snippets/subsnippet.php
@@ -0,0 +1 @@
+<?php snippet('base', slots: true);
diff --git a/site/templates/default.php b/site/templates/default.php
index 74e38ae..9ca23b8 100644
--- a/site/templates/default.php
+++ b/site/templates/default.php
@@ -1 +1 @@
-<h1><?= $page->title() ?></h1>
+<?php snippet('subsnippet', slots: true);

Your setup

Kirby Version
4.8.0

Console output

> Composer\Config::disableProcessTimeout
> @php -S localhost:8000 kirby/router.php
[Mon Aug 25 01:15:56 2025] PHP 8.4.11 Development Server (http://localhost:8000) started
[Mon Aug 25 01:16:02 2025] [::1]:54971 Accepted
[Mon Aug 25 01:16:02 2025] [::1]:54971 Closing

Your system (please complete the following information)

  • Device: Desktop
  • OS: Windows 10
  • Browser: Firefox
  • Version: 142.0

Workaround

Call endsnippet() at the end of either the snippet of step 2, or the template of step 3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions