PHPackages                             hananils/kirby-snippetwhen-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hananils/kirby-snippetwhen-helper

ActiveKirby-plugin[Utility &amp; Helpers](/categories/utility)

hananils/kirby-snippetwhen-helper
=================================

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

1.0.1(4y ago)746[1 issues](https://github.com/hananils/kirby-snippetwhen-helper/issues)MITPHP

Since Jun 23Pushed 1y ago3 watchersCompare

[ Source](https://github.com/hananils/kirby-snippetwhen-helper)[ Packagist](https://packagist.org/packages/hananils/kirby-snippetwhen-helper)[ RSS](/packages/hananils-kirby-snippetwhen-helper/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

[![Kirby snippetWhen Helper](.github/title.png)](.github/title.png)

**snippetWhen** is a helper function for [Kirby 3](https://getkirby.com) to conditionally embed snippets.

Note

Please check out the online documentation at [kirby.hananils.de/plugins/snippetwhen-helper](https://kirby.hananils.de/plugins/snippetwhen-helper) for further information.

Installation
------------

[](#installation)

### Download

[](#download)

Download and copy this repository to `/site/plugins/snippetwhen-helper`.

### Git submodule

[](#git-submodule)

```
git submodule add https://github.com/hananils/kirby-snippetwhen-helper.git site/plugins/snippetwhen-helper

```

### Composer

[](#composer)

```
composer require hananils/kirby-snippetwhen-helper

```

Usage
=====

[](#usage)

snippetWhen($snippet, $condition, $expected, $data)
---------------------------------------------------

[](#snippetwhensnippet-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
=======

[](#license)

This plugin is provided freely under the [MIT license](LICENSE.md) by [hana+nils · Büro für Gestaltung](https://hananils.de).
We create visual designs for digital and analog media.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~513 days

Total

2

Last Release

1689d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e0465cfa7ef2b9a264429068ddfeb765f3881f9c611048d2e7e95dfad4afbb35?d=identicon)[hananils](/maintainers/hananils)

---

Top Contributors

[![nilshoerrmann](https://avatars.githubusercontent.com/u/25466?v=4)](https://github.com/nilshoerrmann "nilshoerrmann (5 commits)")

---

Tags

kirby3-plugin

### Embed Badge

![Health badge](/badges/hananils-kirby-snippetwhen-helper/health.svg)

```
[![Health](https://phpackages.com/badges/hananils-kirby-snippetwhen-helper/health.svg)](https://phpackages.com/packages/hananils-kirby-snippetwhen-helper)
```

###  Alternatives

[getkirby/cms

The Kirby core

1.5k584.8k474](/packages/getkirby-cms)[medienbaecker/kirby-modules

Easily add modules to your pages

895.5k1](/packages/medienbaecker-kirby-modules)[distantnative/retour-for-kirby

Manage redirects and track 404s right from the Kirby CMS Panel

14698.5k1](/packages/distantnative-retour-for-kirby)[arnoson/kirby-vite

Vite helper for Kirby CMS

9765.1k3](/packages/arnoson-kirby-vite)[bnomei/kirby3-dotenv

Kirby Plugin for environment variables from .env

4149.6k2](/packages/bnomei-kirby3-dotenv)[medienbaecker/kirby-alter

242.1k](/packages/medienbaecker-kirby-alter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
