Hi there !
I’m trying to create a snippet suggestion system with a plugin.
I register a single router snippet wich build suggestions snippet base on some parameter like blueprint, display (see code).
But if my snippets suggestions are not registered inside my plugin index file it doesn’t work.
I register my snippet router :
Kirby::plugin('db/helper', [
'snippets' => [
'displays/pages/_' => __DIR__ . '/snippets/displays/pages/_.php',
An I would like its to chosse the first template finded like code below (in comments, the suggestions)
<?php
$display = $display ?? 'default';
$blueprint = $item->blueprint()->name();
$params = $params ?? [];
snippet(
[
// displays/pages/news/card
'displays/' . $blueprint . '/' . $display,
// displays/pages/card
'displays/' . explode('/', $blueprint)[0] . '/' . $display,
// displays/pages/default
'displays/' . explode('/', $blueprint)[0] . '/default',
// displays/card
'displays/' . $display,
// displays/default
'displays/default',
],
[
'item' => $item,
'params' => $params
]
);
The main advantage is to provide a generic plugin which handle a default rendering.
Then, in the site folder, I would like to be able to override plugin default rendering by including new files… I can’t register all suggestion, as I don’t know them in advance…
How to do that ?