My website uses the zend framework and runs in a sub folder, for example: http://www.example.com/sub/folder. Now I want to prepend my css links with /sub/folder/ to make the css load in pages like http://www.example.com/sub/folder/product/abc, I thought I found a view helper to do this BaseUrl but BaseUrl seems only to work in actual view files and not in a bootstrap class.
Does anybody know the reason for this and an exceptable workaround?
This is Snippet of my boodstrap class.
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initStylesheet()
{
$this->_logger->info('Bootstrap ' . __METHOD__);
$this->bootstrap('view');
$this->_view = $this->getResource('view');
$this->_view->headLink()->appendStylesheet($this->_view->baseUrl('/css/main.css'));
}
}
I found the reason why the
baseUrl()view helper didn’t work in theBootstrap. It’s becauseZend_Controller_Frontdidn’t have aZend_Controller_Request.So to solve the issue I added an other resource method to initialize the request.