Question

I'm doing my first zend application, following the official user's guide, I set up a standard zend application (with zend studio 9 and ZF 1.11) and I want to add images and CSS stylesheets to my .phtml pages. When I put the css files in "myApplicationName/public/css" everything works fine, but when I try to put them in another directory such as "myApplicationName/application/layouts/css", they don't get considered, what kind of paths should i use to link them to phtml pages?

I've tried relative paths, things like :

<link rel="stylesheet" type="text/css" media="screen" href="../../css/layout_look_like.css" />

and also :

<link rel="stylesheet" type="text/css" media="screen" href="/application/layouts/css/layout_look_like.css" />

but it doesn't seem to work,

I've also tried paths with $this->baseUrl(), but <?php echo $this->baseUrl();?> returns nothing.

thanks for help.

Was it helpful?

Solution

Your CSS files should be inside the public directory. There should be no need to place them in your application directory. If you really need to do it, you could make a symbolic link to the public directory.

To include a CSS file (stored in the public directory) to your view/layout, use:

<?php echo $this->headLink()->appendStylesheet($this->baseUrl('/styles/basic.css')); ?>

OTHER TIPS

CSS, Images, and JS and any other publicly accessible static assets must live under the public folder as this is your web server DOCUMENT_ROOT (ie. http://yourdomain/). Beyond that you can use whatever structure you like.

You have to write like below mentioned code for your layout_look_like.css file

echo $this->headLink()->appendStylesheet($this->baseUrl('/css/layout_look_like.css'));

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top