Hi, I’ve got a Kirby installation and PHP/MySQL-website. Is it possible to use Kirby-snippets as template-parts in my php-site?
I used allready a script (from Kirby 2.0 sneak peek)
// load the bootstrapper
require(‘kirby/bootstrap.php’);
// initialize the site for the first time
$site = site();
// load something from the API
$page = $site->pages()->find('my/awesome/page');
// do something with the page object
echo $page->title();
This works fine, even with snippets - but if I include my footer-snippet with “$site->copyright()” in it - it breaks down. What can I do?
I think the field methods are not loaded with the bootstrap file, that’s why they don’t work in config.php either.
I just tested with launching Kirby after requiring the bootstrap file just as in index.php in a external file and that did do the job, but I’m not really sure if that’s really the way to do it.
To use the $site->copyright()->kirbytext() method, you need to load the so-called extension files:
kirby()->extensions();
before calling the snippet. Using kirby()->launch() will output the full page source of the “current page”, but if you only need the snippet, using it like this should work.