I can link assets manually with relative URL by forgoing |theme
filter, however plugins still use absolute path, which creates issues when I share and test my project. Is there a native way to make October use relative urls?
Asked
Active
Viewed 722 times
0

qwaz
- 1,285
- 4
- 23
- 47
-
The AssetMaker always returns absolute URLs ( https://github.com/octobercms/october/blob/master/modules/system/traits/AssetMaker.php#L271 ). If you really need this, the only way I can think of is registering a middleware and modify the response to rewrite any absolute URLs. This however does not sound very performant and will probably be error prone. What is the exact issue you are having using the absolute paths? – Alex Guth Apr 13 '17 at 14:42
-
Sharing my local environment with clients and colleagues suing ngrok.io, it expects relative path to load website css, js, and etc. So plugin scripts won't load up. – qwaz Apr 13 '17 at 15:19
-
1I think the way to go is a middleware then. – Alex Guth Apr 13 '17 at 15:25
1 Answers
0
You can have assets in your plugin folder. Then in your component's onRun function, load them.
public function onRun()
{
$this->addCss('/plugins/cleanse/pvpactions/assets/css/actions.css');
$this->addJs('/plugins/cleanse/pvpactions/assets/js/axios.min.js');
}
http://octobercms.com/docs/plugin/components#component-assets

PaulELI
- 444
- 6
- 16