Issue: Customising folder paths breaks the Panel

Hey all,

New to Kirby and really enjoying the development experience so far :smile:

I’ve had an issue whilst trying to customise parts of my folder structure that should be configurable according to the documentation. I’d like to relocate the ./assets/avatars and ./thumbs folders, which are both configurable paths in $kirby->roots which were used as below according to the documentation.

However, the Panel plugin no longer works whilst these lines are present, not loading at all in a browser. I’ve tried other folder locations and isolating one customisation at a time, but any path modification seems to break the Panel. At all stages, the referenced directories were present and correct, and whilst testing I even left them in both locations — so it seems it is simply setting these keys that is upsetting the plugin.

site.php

<?php

$kirby = kirby();

// Custom roots
$kirby->roots->avatars = $kirby->roots()->index() . DS . 'assets' . DS. 'img' . DS . 'avatars';
$kirby->roots->thumbs = $kirby->roots()->index() . DS . 'assets' . DS. 'img' . DS . 'thumbnails';

// Custom URLs
$kirby->urls->avatars = $kirby->urls()->index() . '/assets/img/avatars';
$kirby->urls->thumbs = $kirby->urls()->index() . '/assets/img/thumbnails';

If someone has any idea on a possible cause or can offer any help, it would be much appreciated. I’d just really like to relocate these (particularly ./thumbs in the root!), and as a first-party plugin, any global configuration changes shouldn’t be breaking things :\

Thank you

Update!

  • Created an issue on GitHub.
  • Fixed my problem for now by setting $kirby->urls->index explicitly.
  • Developer might be planning auto-detection for this for Panel v2.2.0. :smile:

Comparing your code with the docs, I would say, there ist a . DS . missing. Try

$kirby->roots->avatars = $kirby->roots()->index() . DS  . 'assets' . DS. 'img' . DS . 'avatars';
$kirby->roots->thumbs = $kirby->roots()->index() . DS . 'assets' . DS. 'img' . DS . 'thumbnails';

(This is untested)

Oh, my bad — for the question I cut down the full path for simplicity and accidentally removed the first . DS . here, but it has been present in my source code (amended above now).

More information

When inspecting the blank Panel page with my site.php active it is trying to load assets from a different URL:

http://localhost/projects/kirby-starter/panel/panel/assets/css/panel.css (with path changes)
http://localhost/projects/kirby-starter/panel/assets/css/panel.css (normal)

And causing the problem is the additional panel/ directory reference. Interestingly, if I then visit http://localhost/projects/kirby-starter/panel/panel/, part of the markup for the panel loads! The paths have got confused somewhere. I would prefer not hacking to fix this, as I have Panel as a Git submodule.

Is there anything else in your site.php than the code from your first post?

Hi distantnative,

Nothing else except a header comment, and the rest of the files have been left alone, I’m pretty much just starting from the getkirby/plainkit repo.

Could you open an issue over at github for this? Issues · getkirby-v2/panel · GitHub

Helps us to better keep track of them. Maybe add your customs ite.php to the issue description + that part:

When inspecting the blank Panel page with my site.php active it is trying to load assets from a different URL:

http://localhost/projects/kirby-starter/panel/panel/assets/css/panel.css (with path changes)
http://localhost/projects/kirby-starter/panel/assets/css/panel.css (normal)

Thanks!

Sure thing, will do when I get back to my computer. Many thanks :slight_smile:

Can you explicitly add what/how/where you set $kirby->urls->index ? I’ve run up against the same issue, and am not sure what you set the index to to fix the problem!

Thanks,

Hi Luc,

I added this line to config.php to set the site URL - hope this helps :smile:

/*

---------------------------------------
URL Setup
---------------------------------------

By default kirby tries to detect the correct url
for your site if this is set to false, but if this should fail
or you need to set it on your own, do it like this:

c::set('url', 'http://yourdomain.com');

Make sure to write the url without a trailing slash.

*/

c::set('url', 'http://localhost:8000');
1 Like

like this? https://github.com/getkirby/panel/issues/447#issuecomment-191718413
does not work for me. :frowning: using kirby 2.2.3.

The site.php file where you define your paths is loaded before Kirby even knows where your config file is (you can modify that path as well). So you can’t get the value from the config.

i see. thank you very much.