Hi, i am brand new to kirby. I try to create my first plugin, an render a plugin-template to a page…
http://my-domain.de/test/
simple root
$kirby->set('template', 'my-page', __DIR__ . DS.'templates'.DS.'test.php');
$kirby->set('route', array(
'method' => 'GET',
'pattern' => 'test',
'action' => function () {
$my_data = [ 'foo' => 'thats foo',
'bar' => 'thats bar'];
return array('my-page', $my_data);
}));
I figured out that i have to place a dummy file in content folder to get it work:
/content/my-page/my-page.txt
So… this works perfectly. My test template in rendered within the rest of the page.
Subfolders
Now i tried to go a step further. I have a few Root-Pages (that also form the Main Menue). Under one of them are few Subpages, and one of these Subpages should be rendered by my plugin:
http://my-domain.de/mitglied/laufzettel/
Following the above Schema i created a Dummy Page in the content Folder:
/content/7-mitglied/5-laufzettel/laufzettel.txt
and modified my Plugin
$kirby->set('template', 'mitglied/laufzettel', __DIR__ . DS.'templates'.DS.'test.php');
$kirby->set('route', array(
'method' => 'GET',
'pattern' => 'mitglied/laufzettel',
'action' => function () {
$my_data = [ 'foo' => 'thats foo',
'bar' => 'thats bar'];
return array('mitglied/laufzettel', $my_data);
}));
But that doesnt work. My Plugin-Template is ignored. Any ideas how to get this scenario to work?