3

I create a plugin for application installation in CakePHP. In my plugin folder I have create the folder structure:

/app
    /Plugin
        /Install
            /Controller
                /Component
            /Model
                /Behavior
            /View
                /Helper
                /Install
                /Layouts
                    /Installer.ctp
            /webroot
                /css
                    default.css

Now in my Installer.ctp I have enter that code:

<?php

    echo $this->Html->css('/Install/default.css');

?>

but the CakePHP return to me the URL /cp/Install/default.css

Any idea on how to make the plugin to load the correct file from within the plugin folder webroot ?

2 Answers 2

9

it should be

echo $this->Html->css('/install/css/default');

also note the lowercase i

Sign up to request clarification or add additional context in comments.

3 Comments

js would be $this->Html->script('/install/js/default');
I can't get this to work - going to mysite.com/plugin_name/css/default.css gives a "PluginName.CssController not found" error. Can you help?
did you read book.cakephp.org/2.0/en/appendices/… - and do you have the AssetDispatcher in your filter Configure::write('Dispatcher.filters')?
9

I know it's an old post, but I'd like to share another approach: you can pass 'PluginName.css-file' as parameter:

echo $this->Html->css('Install.default');

Works like a charm.

2 Comments

I like this approach, I think this is better, thanks
Throws me a Missing Controller error, the files are there though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.