views:

61

answers:

2

hello every one i created a controller and actions in zend. if i type "http://localhost/cms/public/controller" then the css file is loaded correctly but if i type "http://localhost/cms/public/controller/action"

then headlink appears like

href='http://localhost/cms/public/controller/css/style.css" and it does not work. Please help me!!

A: 

You have your css path set to "css/style.css". Set the css path relative to the root path. If your css is in /html/style/css/style.css, the link would be "/style/css/style.css"

Always remember the leading slash and make the static paths relative to the root dir(of the website).

dekomote
I think my webserver is looking for css file inside /controller folder inside my root directory. Could you please tell me where can i find this url root path.
explorex
I think i did $this->headLink()->appendStylesheet('css/layout.css'); echo $this->headLink(); in my layout.phtml file. Do i have to add root path right here?
explorex
$this->headLink()->appendStylesheet('/css/layout.css'); echo $this->headLink(); Try this line. If the css folder is inside your html folder, this should work. Note the leading slash in the path. That means that the path is relative to the root html directory
dekomote
A: 

Hi ! ,

this is the correct way to add css & java script to ZF Application

 <?php
        $this->headLink()->appendStylesheet($this->baseUrl("css/reset.css"))
                ->appendStylesheet($this->baseUrl("css/text.css"))
                ->appendStylesheet($this->baseUrl("css/960.css"))
                ->appendStylesheet($this->baseUrl("css/demo.css"));
        echo $this->headLink();
        $this->headScript()->appendFile($this->baseUrl("js/jquery-1.4.2.min"))
                    ->appendFile($this->baseUrl("js/jquery-ui-1.8.2.custom.min"));
            echo $this->headScript();?>
tawfekov
thanks...a lot...it worked
explorex
More than Welcome :)
tawfekov