I think below is the decent/ZF way to do it:
//application/Bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView()
{
// Initialize view
$view = new Zend_View();
$view->doctype('XHTML1_STRICT');
$view->headLink()->headLink( array( 'rel' => 'favicon',
'href' => $view->baseUrl( 'favicon.ico' ),
'type' => 'image/x-icon' ));
// Add it to the ViewRenderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
'ViewRenderer'
);
$viewRenderer->setView($view);
// Return it, so that it can be stored by the bootstrap
return $view;
}
}
And in head portion of the layout file( application/layouts/scripts/layout.phtml ):
<?php echo $this->headLink()?>
Shall be aware that there may exist a better way.
Comments
adam (not verified)
22 June, 2011 - 19:39
Permalink
doesn't work
it doesn't work for me. I still see the default zend icon..
Exooöl
22 June, 2011 - 21:35
Permalink
Make sure you have the favicon file located at the right place
Please note, in code of this line
the "favicon.ico" file should be located at folder: /application_root_path/public/
The file tree should look like below:
|-- application
| |-- Bootstrap.php
| |-- configs
| | `-- application.ini
| |-- controllers
| | `-- IndexController.php
|-- library
| |-- Zend
| `-- ZendX
|-- public
| |-- css
| | `-- global.css
| |-- favicon.ico
| |-- images
| |-- index.php
| `-- js
.........
If the file location is right, then you may want to clear the cache of your browser for a try.
Add new comment