I initialize my placeholders for my global layout within the Bootstrap.php as described here.
public function _initPlaceholders()
{
$this->bootstrap('View');
$view = $this->getResource('View');
$view->doctype('XHTML11');
$view->headTitle('Foo Bar Title')
->setSeparator(' :: ');
$view->headMeta()->appendHttpEquiv(
'content-type',
'application/xhtml+xml; charset=UTF-8'
);
$view->headMeta()->appendName('robots', 'index,follow');
$view->headLink()->appendStylesheet('/styles/styles.css', 'screen')
->appendStylesheet('/styles/print.css', 'print');
}
The rendered HTML looks correct.
<title>Foo Bar Title</title>
<link href="/styles/styles.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/styles/print.css" media="print" rel="stylesheet" type="text/css" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="robots" content="index,follow" />
But the CSS doesn’t get loaded correctly because Zend_Controller thinks it’s a controller or something. When I try to open the CSS files the following error occurs:
Fatal error: Uncaught exception
‘Zend_Controller_Dispatcher_Exception’
with message ‘Invalid controller
specified (error)’
Any hints?
[update]
Ok, just added the following line to my .htaccess file and all works as expected now…
RewriteRule
!.(js|ico|txt|gif|jpg|png|css|htc|swf|htm)$
index.php
A typical Zend project layout looks something like this:
Does yours look similar? Specifically, do you have CSS and JavaScript files somewhere under the public folder (and not the application folder)? If so, can you review file permissions?
Also, I recommend reviewing file permissions. If the CSS files aren’t readable by the Apache process, then Apache won’t be able to serve them.