Hello, I’ve setup a basic plugin. Within my plugin folder I have a ‘snippets’ folder as recommended in Plugin Basics. Does this mean I can include files from that folder within my plugin, say from the index.php file of my plugin? See example below.
snippet('mysnippet', ['myvar' => 'myvalue', true);
So would this pull in ‘mysnippet.php’ from the plugin’s snippet folder? Please advise.
Putting snippets into a snippets folder alone does not mean you can use them, you also have to register the snippets with the snippets extension in your plugin, see Snippets | Kirby CMS
Then you can use them with the snippets function like every other snippets in the /site/snippets
folder.
1 Like
Thanks! Perfect. It works now that the plugin snippets are registered. Hmmm… I wonder if it’s worth using snippets like this and not just an include, but I do need to pass the page object and I’m utilizing that third parameter so the snippet outputs a value… so perhaps in my case it is worth it to take advantage of Kirby’s snippets in my plugin.