CakePHP fav icon
How can the default fav icon be开发者_C百科 changed in CakePHP?
Simply replace the file app/webroot/favicon.ico
with your own version.
Use Html Helper
, put it in <head>
tag:
(File /app/View/Layouts/default.ctp
)
echo $this->Html->meta ( 'favicon.ico', '/favicon.ico', array (
'type' => 'icon'
) );
You also use hyperlink, for example, I used StackOver Flow's favicon:
echo $this->Html->meta ( 'favicon.ico', 'http://cdn.sstatic.net/stackoverflow/img/favicon.ico?v=038622610830', array (
'type' => 'icon'
) );
Of course, You maybe put favicon five in another folder in your web resources folder. For example: put favicon.ico in /app/webroot/img/decor/favicon.ico
:
echo $this->Html->meta ( 'favicon.ico', '/img/decor/favicon.ico', array (
'type' => 'icon'
) );
More information: "favicon.ico" is the convention. Don't chage file name.
Create or choose a favicon: http://www.favicon.cc/ Or see HTML source (Ctrl + U) from another website, and copy & paste.
Work with CakePHP lastest version (2.6.0). Reference: http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#inserting-well-formatted-elements
Simply replace the favicon inside app/webroot with your own *.ico favicon. And you're done ! If your favicon won't show after you done as above, Re-refresh your browser Or, simply clear web history.
Given like this
<link rel="shortcut icon" type="image/x-icon" href="<?php echo $this->webroot; ?>img/bullet.jpg">
In this way I got the favicon.In that case no need to rename the default favicon.ico
In your webroot folder change cake.icon.png
image instead of your image.
In your view\layouts\default.ctp
just add this code
echo $this->Html->meta('icon');
Well you need to delete the default favicon.ico icon file from webroot directory and place your own picture. But make sure you convert that picture in icon format and rename it to favicon. I think it should work because it worked for me.
I had to put the icon into the /img/ folder - it just wouldn't accept it in the root folder.
you can use this for displaying favicon icon.
<link rel="shortcut icon" type="image/x-icon" href="<?php echo FULL_BASE_PATH; ?>/favicon.ico" />
Replace your favicon with app/webroot/favicon.ico and wait for sometime, as it require some time to reflect on browsers.
Check your layout.ctp file to check if your favicon is located at the right place.
Put this in your header
<?php echo $this->Html->meta(
'favicon.ico',
'/favicon.ico',
array('type' => 'icon')
);
?>
The size to use is 16x16, png renamed in .ico
<?php
echo $this->Html->meta('favicon.ico','/favicon.ico', array('type' => 'icon'));
?>
set the following snippet in your layout:
Html->meta('favicon.png','img/favicon.png',array('type' => 'icon')); ?> // favicon.png is your image in webroot/img
精彩评论