Absolute symlinks for plugin assets

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.csshome/www/MYACCOUNT/html/site/plugins/auf-icons/assets/css/icon-block.css

How can I achieve the desired result?

Cheers
Peter

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

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

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'
]);

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

That works @texnixe, thank you very very much!!!

@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,
   ...
]);

To my future-future self:

Delete the media/-folder-contents to regenerate the symlinks after updating already existing sites.

how did you know you need the absolute path? did your provider’s support tell you this?

i am working on a new project for a new customer on a new server and sadly the symlinks are not working for me either. same behaviour as you. when i delete everything, the first call works, but then i get 403 the whole time when refreshing.

just to be fast and since those files rarely change, i just deleted the symlinks and uploaded the assets for the 3 plugins that were having issues, so it works now. but it would be nice to have the website working as intended

i would appreciate your input!

sorry @squareclouds, i can´t remember.
i guess i asked the provider for support and build some testcases on server.

does the workaround not work for you?

ok, thanks :slight_smile: no, the workaround didnt work for me. i went over some things and i think at the end the symlinks might be blocked by the provider. so i will check with them. thank you!