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.css β†’ home/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.