snippetWhen is a helper function for Kirby 3 to conditionally embed snippets.
Download and copy this repository to /site/plugins/snippetwhen-helper
.
git submodule add https://github.com/hananils/kirby-snippetwhen-helper.git site/plugins/snippetwhen-helper
composer require hananils/kirby-snippetwhen-helper
Conditionally embeds a snippet:
$snippet
: the name of the snippet$condition
: a condition that either evaluates totrue
orfalse
$expected
: the expected result of the condition, defaults totrue
$data
: data object passed to the snippet
snippetWhen('article', $page->category()->isNotEmpty());
This plugin is provided freely under the MIT license by hana+nils · Büro für Gestaltung.
We create visual designs for digital and analog media.