With this plugin you don’t need to create a new field every time you need something simple in the panel. This field calls for a snippet that you have set in your blueprint.
Much more information and instructions is on Github.
With this plugin you don’t need to create a new field every time you need something simple in the panel. This field calls for a snippet that you have set in your blueprint.
Much more information and instructions is on Github.
for everything that makes kirby easier to extend!
I renamed the field, released a new version and made it so much simpler…
Blueprint
fields:
my_logic_field:
title: My logic field
type: logic
config.php
kirby()->hook('pluginLogicField', function($field, $page) {
echo $page->title();
echo $field->name();
//snippet('some-logic', ['field' => $field, 'page' => $page]);
});
1.0
Version 1.1
Now it’s even simpler to add a new custom field. Instead of a hook, a simple c::set
option is used.
Blueprint
fields:
my_logic_field:
title: My logic field
type: logic
config.php
c::set('plugin.logic.field', function($field) {
return '<p>' . $field->name() . ' ' . $field->page->title() . '</p>';
});
github.com/jenstornell/kirby-logic-field
1.2
$page
as well.$page
separated from $field
. Two objects instead of just $field
.To use a snippet a code like this would work:
c::set('plugin.logic.field', function($field, $page) {
return snippet('logic-' . $page->intendedTemplate(), ['field' => $field, 'page' => $page], true);
});
The snippet would then be called like logic-default
and have access to $field
and $page
objects.