Here is the setup:
- editor role can edit site.yml without issue.
- site.yml has a part reserved for admin (a “theme settings” tab)
- for that I used the double site.yml file technique in a plugin with the following code:
Kirby::plugin('jug/role-specific-site-blueprints', [
'blueprints' => [
'site' => function () {
if (($user = kirby()->user()) && $user->isAdmin()) {
return Data::read(__DIR__ . '/blueprints/site.admin.yml');
} else {
return Data::read(__DIR__ . '/blueprints/site.editor.yml');
}
},
]
]);
In that site.admin.yml, in the tab that only admin can access there is a setting to choose a “footer style” among several. Let’s say we chose “footer 2”.
In another tab, accessible by both editor and admin, the content can be altered by both of them, but a field is defined like so:
footerSubContent:
label: A phrase all the way down under the footer
type: text
when:
footerStyle: footer-02
This field only appears if the “theme setting” “footer style” field is set to footer 2. Pretty straight forward.
The editor can see this field.
But in its “view”, the site.yml does not actually contain a footerStyle setting.
What happens is that he can actually see AND edit the footerSubContent field… but when saving, the modification disappears.
Is that a bug or a feature? And if it’s a feature, is there a better way to do what I described?