hananils / kirby-snippetwhen-helper
Helper function for Kirby to embed snippets only when a condition is met.
Package info
github.com/hananils/kirby-snippetwhen-helper
Type:kirby-plugin
pkg:composer/hananils/kirby-snippetwhen-helper
1.0.1
2021-11-18 13:00 UTC
Requires
README
snippetWhen is a helper function for Kirby 3 to conditionally embed snippets.
Note
Please check out the online documentation at kirby.hananils.de/plugins/snippetwhen-helper for further information.
Installation
Download
Download and copy this repository to /site/plugins/snippetwhen-helper.
Git submodule
git submodule add https://github.com/hananils/kirby-snippetwhen-helper.git site/plugins/snippetwhen-helper
Composer
composer require hananils/kirby-snippetwhen-helper
Usage
snippetWhen($snippet, $condition, $expected, $data)
Conditionally embeds a snippet:
$snippet: the name of the snippet$condition: a condition that either evaluates totrueorfalse$expected: the expected result of the condition, defaults totrue$data: data object passed to the snippet
snippetWhen('article', $page->category()->isNotEmpty());
License
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.
