hananils / kirby-snippetwhen-helper
Helper function for Kirby to embed snippets only when a condition is met.
Installs: 43
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 5
Forks: 0
Open Issues: 1
Type:kirby-plugin
Requires
README
snippetWhen is a helper function for Kirby 3 to conditionally embed snippets.
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 totrue
orfalse
$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.