pesto
April 24, 2023, 3:20pm
1
Kirby generates relative symlinks for plugin assets like:
icon-block.css β /html/site/plugins/auf-icons/assets/css/icon-block.css
Unfortunatley my host needs an absolute path like:
icon-block.css β home/www/MYACCOUNT /html/site/plugins/auf-icons/assets/css/icon-block.css
How can I achieve the desired result?
Cheers
Peter
bnomei
April 24, 2023, 7:42pm
2
as far as i know kirby will redirect plugin assets to plugin folders but not via creating a symlink on the filesystem but using the built in router.
what does the code look like where you need the absolute path and get the relative one as well?
There is a route that resolves the paths, yes, but inside that route the PluginAssets::resolve()
method takes care of creating the symlink.
Having said that, I wonder why $plugin->root()
in your environment doesnβt point to the absolute path?
1 Like
pesto
April 25, 2023, 10:27am
4
I double checked:
<?= $kirby->plugin('auf/button')->root() ?>
points relatively to:
/html/site/plugins/auf-button
on the server.
Locally I get the full path.
Can I change something the .htaccess
to make this work
or
can I give Kirby the additional path-information home/www/MYACCOUNT/...
to create the correct symlinks on the server?
Try setting the plugin root to the absolute path (depending on host) in your index.php
pesto
April 25, 2023, 2:01pm
6
IΒ΄ve set the plugin root to the absolute path locally and on server like this:
<?php
include 'kirby/bootstrap.php';
$kirby = new Kirby([
'roots' => [
// 'plugins' => '/Users/pesto/Documents/folder/folder/site/plugins',
'plugins' => '/home/www/ACCOUNTID/html/site/plugins',
],
]);
echo $kirby->render();
Works again locally but on the server I still get the relative path when calling:
<?php
$kirby->plugin('auf/button')->root(); // => '/html/site/plugins/auf-button'
Double checked if the plugin-path is set and it was correct:
<?php
$kirby->root('plugins'); // => /home/www/ACOUNTID/html/site/plugins
I deleted the media folder to regenerate the symlinks.
no success.
the initial load was ok. Then, on page-reload I get 403s for the assets.
what can I do?
One last idea before Iβm at my wits` end:
Set the root here
\Kirby\Cms\App::plugin('auf/button', [
// ...
'root' => 'path-to-folder'
]);
pesto
April 26, 2023, 9:43am
8
IΒ΄m not sure, if I understand you idea correctly. Do you mean like this?
<?php //index.php
include 'kirby/bootstrap.php';
\Kirby\Cms\App::plugin('auf/button', [
'root' => 'path-to-folder'
]);
\kirby();
When I do that I get:
Kirby \ Exception \ DuplicateException (error.duplicate)
The plugin "auf/button" has already been registered
What I meant is add this to your existing plugin, instead of creating a new plugin
pesto
April 26, 2023, 10:13am
10
That works @texnixe , thank you very very much!!!
pesto
April 26, 2023, 11:37am
11
@texnixe : Should I open an issue on github for this?
For my future self:
<?php
Kirby::plugin('auf/button', [
'root' => ($pluginsRoot = option('pluginsRoot')) ? ($pluginsRoot .'/'. basename(dirname(__FILE__))) : NULL,
...
]);
pesto
June 1, 2023, 7:34pm
12
To my future-future self:
Delete the media/
-folder-contents to regenerate the symlinks after updating already existing sites.