I am building a plugin and need to access the assets from the plugin at the frontend. I read in other Topic and in the documentation that plugin assets should automatically get transferred to the media-folder. However, that’s not the case for me. I am wondering now, if I miss something of something is off with my setup / local server?
Here a minimal example:
use Kirby\Cms\App;
// Register plugin
App::plugin('pluginauthor/pluginname', [
'assets' => [
'css' => 'assets/styles.css',
]
]);
You certainly can. No need to register the assets like you did, just put them in the assets
folder.
Then, in your frontend code, use:
<?= App::plugin('author/name')->asset('styles.css') ?>
Thanks for your help. Sadly your frontend code doesn’t have any output. I used your code as well as
<?= App::plugin('author/name')->asset('assets/styles.css') ?>
The last output I can get is from
<?php print_r(Kirby::plugin('author/name')); ?>
with following result
Kirby\Cms\Plugin Object
(
[updateStatus:protected] =>
[name:protected] => author/name
[extends:protected] => Array
(
[assets] => Array
(
[css] => assets/styles.css
)
)
...
texnixe
November 29, 2024, 1:37pm
4
Remove the assets part here from the path, as in the example @tobimori posted.
As I tried to mention above…
I tried both options without any success. Sadly the apache error-log also keeps empty. Any idea where to look next?