1

Im using CakePHP 2.0 as a framework for my website, I'm having some difficulty with the CSS. Basically what is going wrong is that I have my CSS file being defined on the default.ctp page. It works on this page, however if I navigate to localhost/evolvidsnew/users/login the css is not being used so theres no background colours or position changes etc on the default.ctp I have used the following line,

<link rel="stylesheet" href="App/webroot/css/style.css"/>

am I doing something wrong here? Would appreciate any help. Thanks in advance!

2
  • Sounds like a path issue. Try an absolute path to your CSS file. Commented Feb 24, 2012 at 16:15
  • 2
    try using just /css/style.css cake uses App/webroot as the main directory Commented Feb 24, 2012 at 16:21

2 Answers 2

2

With default configuration CakePHP redirects all requests to the root of the site to app/webroot.

So for your case you should use /css/style.css

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

Comments

1

To work properly you should use the Html helper from CakePHP core library:

<?php echo $this->Html->css('style'); ?>

This should make the style work on every page.

Oh, and the HtmlHelper should be loaded automatically, if it isn't, add this to your controller class:

public $helpers = array('Html');

For more information about HtmlHelper and other core libraries, visit http://book.cakephp.org/2.0/en/core-libraries.html#helpers

3 Comments

how would this apply if I wanted to load up a jquery file for actions etc?
It is explained in the link I posted. Can be done through echo $this->Html->script('nameofyourfile.js');
yeah i checked out that link and got it sorted many thanks again

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.