There seem to be a lot of small cases where us developers need to increase the functionality of the panel. I think that most of these could be handled with javascript - but it would require making blueprints a little more robust. I suggested in the Kirby Wishlist thread an optional method of creating blueprints that’s similar to CodeIgniter’s form helpers:
// Instead of:
title:
label: Title
type: text
cover:
label: Cover Image
type: select
options:
- images
- audio
// Something like:
echo kirby_field(
'title' => 'title',
'label' => 'Author Name',
'type' => 'text'
)
echo kirby_field(
'title' => 'cover_image',
'label' => 'Cover Image',
'type' => 'select',
'options' => array('images', 'audio'),
'width' => '1/2'
)
if ($user->role() == 'admin') {
echo kirby_field(
'title' => 'bio',
'label' => 'Author Bio',
'help' => 'You are an admin and can edit the bio'
'attributes' => array(
'id' => 'bio',
'data-role' => 'admin'
)
)
} else {
echo kirby_field(
'title' => 'bio',
'label' => 'Author Bio',
'readonly' => true,
'attributes' => array(
'id' => 'bio',
'data-role' => 'admin'
)
)
}
echo panel_javascript('/assets/panel_js/author.js')
It’s much more verbose, but would allow for:
- using PHP logic to create the forms
- allow for the retrieval of other site data
- allow for javascript manipulation
- (e.g., if option A is selected on
#radio-field
, display additional fields X Y and Z)
- (e.g., if option A is selected on