Plugin CSS directories bug
Reported by Bancer | March 22nd, 2010 @ 05:07 PM | in Future
I use CSS in my plugin. Everything is set up as described in the
manual here
http://book.cakephp.org/view/742/Plugin-Images-CSS-and-Javascript.
Everything is fine if I use .htaccess files. In my layout I
have
<?php echo $html->css('/my_plugin/css/my_css'); ?>
If I use .htaccess files with mod_rewrite enabled it generates this
html:
<link rel="stylesheet" type="text/css" href="/cakephp-1.2.6/my_plugin/css/my_css.css" />
The site is located at http://localhost/cakephp-1.2.6.
If I do not use .htaccess files and set up built in pretty URLs
as described in the manual here http://book.cakephp.org/view/333/A-Note-on-mod_rewrite
the generated html code does not see css file - the directory is
wrong:
<link rel="stylesheet" type="text/css" href="/cakephp-1.2.6/app/webroot/my_plugin/css/my_css.css" />
It looks like $html->css() does not handle plugin stylesheet routing correctly when I do not use mod_rewrite.
Comments and changes to this ticket
-

Mark Story March 22nd, 2010 @ 08:46 PM
- → Tag changed from pretty urls, css, directories, mod_rewrite, plugins, routing to css, enhancement, mod_rewrite, plugins
- → Milestone set to 1.3.0
There is no support for non-mod_rewrite use of plugin assets at this time. You would need to manually include the index.php and any other parameters you need for your server that doesn't support url rewriting.
Moving to enhancement as this isn't part of the current features of plugin assets, and I don't think this worked in 1.2 either.
-

Bancer March 23rd, 2010 @ 04:53 AM
I suggest to make it clear in the manual http://book.cakephp.org/view/742/Plugin-Images-CSS-and-Javascript that the proposed method to include plugins CSS, Javascript and images is valid only if mod_rewrite is used.
It would be also nice to have an alternative example in the manual, when mod_rewrite is not used.
What would be the php code that would include CSS correctly both when mod_rewrite is used and when it is not used?
-

Bancer March 23rd, 2010 @ 06:19 PM
I don't know how well but I handled the issue this way:
if(is_file(APP.'.htaccess')){ echo $html->css(array('/my_plugin/css/my_css')); }else{ echo $html->css(array('../../plugins/my_plugin/vendors/css/my_css')); } -

-

Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
Repository is at http://github.com/cakephp/cakephp
Creating a bug report
When creating a bug report, please include as much relevant information as possible. Please include code to reproduce the issue. Or even better, make a unit test. Either change an existing test or add a new test to show that the expected behavior is not occuring.