Last active
August 29, 2015 13:57
-
-
Save nils-werner/9686081 to your computer and use it in GitHub Desktop.
Kirby snippet sections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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