Panel custom css bug

Hi, the config below is still not working.

return [
  'panel' => [
    'css' => 'assets/css/custom-panel.css'
  ]
];

i found some code for custom js in the kirby core /kirby/views/panel.php like this:

<?php if (isset($config['js'])) : ?>
    <script nonce="<?= $nonce ?>" src="<?= Url::to($config['js']) ?>" defer></script>
  <?php endif ?>

But for custom css the code block isn’t there.
Is this a bug in kirby 3.5.7?

So… if i add this code block to the panel.php the config for custom css works:

<?php if (isset($config['css'])) : ?>
      <link nonce="<?= $nonce ?>" rel="stylesheet" href="<?= Url::to($config['css']) ?>">
 <?php endif ?>

No, definitely not.

Do you have more in your config.php then this one return statement?

Hi, yes in my config is also an array key for hooks and the debug mode is enabled

That’s exactly the problem: you can only have one return statement. Everything afte the first return is ignored. You can read about return here: PHP: return - Manual

Oh sorry, i misunderstood your answer…
No there is not more than one return statement… but the config array has more keys…

array(4) {
  ["debug"]=>
  bool(true)
  ["panel"]=>
  array(1) {
    ["css"]=>
    string(27) "assets/css/custom-panel.css"
  }
  ["api"]=>
  array(1) {
    ["csrf"]=>
    string(4) "test"
  }
  ["hooks"]=>
  array(3) {
    ["user.create:after"]=>
    object(Closure)#50 (1) {
      ["parameter"]=>
      array(1) {
        ["$user"]=>
        string(10) "<required>"
      }
    }
    ["user.update:after"]=>
    object(Closure)#49 (1) {
      ["parameter"]=>
      array(2) {
        ["$newUser"]=>
        string(10) "<required>"
        ["$oldUser"]=>
        string(10) "<required>"
      }
    }
    ["user.login:after"]=>
    object(Closure)#48 (1) {
      ["parameter"]=>
      array(2) {
        ["$user"]=>
        string(10) "<required>"
        ["$session"]=>
        string(10) "<required>"
      }
    }
  }
}

Oh, ok. And the file exists at the given location?

yes, that’s a debug output after laoding this file… if i change the key css into js, then i see a new script tag in the source tag… but css not work :frowning: unless i add the code from my first post in the panel.php

This is the code that loads custom css

 <?php if ($customCss) : ?>
  <link nonce="<?= $nonce ?>" rel="stylesheet" href="<?= $customCss ?>">
  <?php endif ?>

yeah but it seems that this code don’t work for panel css…
the variable $customCss is filled by methods behinde the function css(‘path/to/css’)

Only the class method addCustomCss() fills the variable $customCss but no script call this function… So the $customCss is always empty :man_shrugging:

EDIT:
Found one line that calls the addCustomCss function:

File: AppErrors.php
Line 75

$handler->addCustomCss(‘whoops.css’);

FIXED the problem…

i run kirby in multisite mode…
kirby checks if the file exists before inlcude the file…
in multisite mode the “global” asset folder is located in the root dir.
i create a new asset folder under the root path and now… i works…