Skip to content

Instantly share code, notes, and snippets.

@nils-werner
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nils-werner/9686081 to your computer and use it in GitHub Desktop.
Save nils-werner/9686081 to your computer and use it in GitHub Desktop.
Kirby snippet sections
<?php
/*
* Snippet Templates
*
* A plugin to inject sections into snippets
*
* Sample Usage:
*
* In your snippet:
*
* <?php section::get('submenu') ?>
*
* In your template:
*
* <?php section::start('submenu') ?>
* <a href="<?php echo $related->url() ?>"><?php echo html($related->title()) ?></a>
* <?php section::end() ?>
*
* Author: Nils Werner
*
*/
class section {
private static $tmpkey = "";
static function get($key) {
echo tpl::get($key);
}
static function set($key, $value) {
tpl::set($key, $value);
}
static function start($key) {
self::$tmpkey = $key;
content::start();
}
static function end() {
tpl::set(self::$tmpkey, content::end(true));
self::$tmpkey = "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment