* Update… The following guide will also works in CakePHP 1.3
In CakePHP 1.2 default layout, favicon are linked through:
1 | <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> |
The problem with this is that when you navigate to other views (except for the default controller and view it loads), the favicon will disappear. This is because the path to the favicon is lost.
There is also a mistake in CakePHP 1.2 Manual at here
The $html->meta has the wrong values fed into it and the parameters doesn’t match what the API desribe at here.
Hence, following the manual in CakePHP 1.2 will not works in displaying the favicon correctly. If we were to use $html->meta parameters as what it was describe in the API like below:
1 | <?php echo $html->meta('icon', /favicon.ico'); ?> |
We will get:
1 | <link href="/favicon.ico" type="image/x-icon" rel="icon" /> |
The correct path is still not being generated !
To resolve this, we made use of $html->url from CakePHP 1.1 :
1 | <?php echo $html->meta('icon', $html->url('/favicon.ico')); ?> |
Now, the path of the favicon will be generated correctly and displayed in all views when using CakePHP 1.2














8 Comments
Thank you!
Hi,
Thanks for the solution but for me the problem was solved with this code :
$html->meta(‘icon’, $html->url(‘../img/favicon.ico’));
Don’t forget to echo that
meta(‘icon’, $html->url(‘/favicon.ico’)); ?>
< ?=means echo in phpI had to do this:
echo $html->meta(‘/img/png’, ‘/img/favicon.png’, array(‘rel’ => ‘icon’));
@JEin
Hey JEin, does my method no longer works?
Thanks! worked for me.. i was not able to display a favicon in views of PagesController.
Yup, if you follow the api, you will find that your views of CakePHP will not display the favicon, except for the main page.
I hope this helps you! The above guide also works in CakePHP 1.3 too!