user3653474
user3653474

Reputation: 3854

Cannot point to webroot directory in plugin folder in Cakephp 3

I want to point javascript and css file to webroot directory in plugin folder. This is my code of the view in the plugin directory

echo $this->Html->css('/PanelAdmin/bower_components/bootstrap/dist/css/bootstrap.min.css');

but this code points to webroot of my parent application. Here PanelAdmin is the plugin name. Please help to sort out my issue. Thanks

Upvotes: 0

Views: 576

Answers (1)

drmonkeyninja
drmonkeyninja

Reputation: 8540

To include CSS assets from a plugin you need to use the plugin dot notation. For example, if you wanted to include the file css/styles.css from your PanelAdmin plugin you would use:-

echo $this->Html->css('PanelAdmin.styles');

See the official docs for details.

Cake uses cssBaseUrl to determine the folder name for the css folder, but I believe you can navigate out of this by using ../ in the file path:-

echo $this->Html->css('PanelAdmin.../bower_components/bootstrap/dist/css/bootstrap.min.css');

Upvotes: 1

Related Questions