Last active
April 4, 2018 12:15
-
-
Save AugustMiller/f0e99dc76062852587e8 to your computer and use it in GitHub Desktop.
Kirby snippet fallback function
This file contains 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 function try_snippet($try, $data = [], $return = false) { | |
$snippets = kirby::instance()->roots()->snippets(); | |
foreach ( $try as $snippet ) { | |
$file = $snippets . DS . $snippet . '.php'; | |
if ( f::exists($file) ) { | |
return tpl::load($file, $data, $return); | |
} else { | |
continue; | |
} | |
} | |
} |
@yoanmalie I generally put these site-specific helpers in site/plugins/
, where they're picked up automatically by Kirby.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@AugustMiller Where did you put this code ? In which file ? Thanks