Pregunta

I have spent the last two nights trying to figure this out.

I have a problem with applying an external stylesheet to every page in my Zend application. The issue is that my external stylesheet is either applied to the index.php file, located in the public folder, or the .phtml view pages which I have created inside the applications folder.

Here's the code I have put inside the Bootstrap.php:

$view->headLink()->appendStylesheet('css/bootstrap.min.css');

In the layout.phtml I have simply called the stylesheet like this:

echo $this->headLink();

I have tried both '$this->baseUrl()' as well as placing a '/' before the 'css' when appending the stylesheet but to no avail.

When I place a '/' before the 'css', my index.php also stops locating the file and instead looks for it in the following location: http://localhost/css/bootstrap.min.css

These methods work fine when I run my application (index.php) in the public folder but all the other .phtml view files and their controllers, which are in the applications folder do not locate the appended stylesheet.

When I view the output, the browser looks for the following path, for the stylesheet when, in this case, I'm loading the 'signup' page: http://localhost/php_project/public/signup/css/bootstrap.min.css

I do not understand why PHP is adding an additional 'signup' folder before the css folder.

Up to now I have been unable to locate an answer anywhere on the net. I don't see it wise to crate multiple files of the same stylesheet across my application.

Your help is much appreciated.

¿Fue útil?

Solución

I usually add a stylesheet in the layout file (not in the Bootstrap) like so:

$this->headLink()->appendStylesheet($this->baseUrl('css/bootstrap.min.css'));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top