Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a favicon in Zend Framework

What's the best way of handling a favicon.ico in Zend framework? I have seen alternatives that requires modification of phtml files like:

$this->headLink()->headLink(array('rel' => 'favicon',
                              'href' => '/img/favicon.ico'),
                              'PREPEND')

or modifications on .htaccess file.

Thanks,

like image 583
polerto Avatar asked Jun 22 '11 10:06

polerto


1 Answers

Three choices:

  • Do nothing - if the favicon is named favicon.ico and sitting in your public directory, most browsers will pick it up
  • Hard-code the <link> tag into your layout
  • Programmatically add the link tag as in your code example

Personally I would go for option 2. There's little point programmatically adding the favicon if it will always be there. It might make sense if the favicon was different for different users, e.g. say your application had a themes system with different favicons for different themes, then you might want to use headLink().

Browsers tend to cache favicons for a long time, so as long as the link tag is appearing in your HTML source then it will eventually update. You can speed up the process by changing the filename, viewing the favicon directly in your browser and/or clearing your browser cache.

like image 108
Tim Fountain Avatar answered Oct 07 '22 09:10

Tim Fountain