Hey everyone.
I would like to have different panel css styles for different user roles. I have already found a solution here in the forum which is this link:
https://forum.getkirby.com/t/different-custom-panel-css-files-for-different-user-roles/14820
How ever i cannot get it running, because of the problem described in the post: “can’t use Kirby()
in the config”. At least I think that is the problem and I don’t know how to solve this.
From the forum this is the solution, but I don’t completely understand it:
https://getkirby.com/docs/reference/system/roots/config
What I did so far: I created a folder admin with the css file custom-panel.css and a folder editor with custom-panel.css. Both inside assets.
My main index.php (in the root) looks like this
<?php
require 'kirby/bootstrap.php';
$kirby = new Kirby();
$user = $kirby->user();
if ($user && $user->role()->id() === 'admin') {
$kirby = new Kirby([
'roots' => [
'assets' => __DIR__ . '/site/assets/admin'
],
]);
} elseif ($user && $user->role()->id() === 'editor') {
$kirby = new Kirby([
'roots' => [
'assets' => __DIR__ . '/site/assets/editor'
],
]);
}
echo $kirby->render();
And my config.php looks like this:
<?php
return [
'panel' => [
'css' => function () {
return kirby()->root('assets') . '/custom-panel.css';
}
],
];
any help how to adapt the config would be great, thank you very much.