Skip to content

Helper function for Kirby to embed snippets only when a condition is met.

License

Notifications You must be signed in to change notification settings

hananils/kirby-snippetwhen-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kirby snippetWhen Helper

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 to true or false
  • $expected: the expected result of the condition, defaults to true
  • $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.

About

Helper function for Kirby to embed snippets only when a condition is met.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages