Domanda

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.

È stato utile?

Soluzione

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')); ?>

Altri suggerimenti

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'));

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top