php CakePHP 收藏夹图标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4537007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 13:22:22  来源:igfitidea点击:

CakePHP fav icon

phpcakephpfavicon

提问by sreenavc

How can the default fav icon be changed in CakePHP?

如何在CakePHP 中更改默认的收藏夹图标?

回答by dhofstet

Simply replace the file app/webroot/favicon.icowith your own version.

只需将文件替换为app/webroot/favicon.ico您自己的版本即可。

回答by Do Nhu Vy

Use Html Helper, put it in <head>tag:
(File /app/View/Layouts/default.ctp)

使用Html Helper,把它放在<head>标签中:(
文件/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:



您还使用超链接,例如,我使用了 StackOver Flow 的 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:


当然,您可以将 favicon 5 放在 Web 资源文件夹中的另一个文件夹中。例如:将 favicon.ico 放入/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.



更多信息:“favicon.ico”是惯例。不要更改文件名。创建或选择一个收藏夹图标:http: //www.favicon.cc/或从另一个网站查看 HTML 源代码 (Ctrl + U),然后复制并粘贴。

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

使用 CakePHP 最新版本 (2.6.0)。参考:http: //book.cakephp.org/2.0/en/core-libraries/helpers/html.html#inserting-well-formatted-elements

回答by Paul LeJoy

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.

只需将 app/webroot 中的 favicon 替换为您自己的 *.ico favicon。大功告成!如果您的网站图标在您完成上述操作后没有显示,请重新刷新您的浏览器,或者,只需清除网络历史记录。

回答by sreenavc

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

这样我就得到了 favicon.In 这种情况下不需要重命名默认的 favicon.ico

回答by Rusty Divine

I had to put the icon into the /img/ folder - it just wouldn't accept it in the root folder.

我不得不将图标放入 /img/ 文件夹 - 它只是不会在根文件夹中接受它。

回答by Lakhwinder Singh

you can use this for displaying favicon icon.

您可以使用它来显示网站图标。

<link rel="shortcut icon" type="image/x-icon" href="<?php echo FULL_BASE_PATH; ?>/favicon.ico" />

回答by User

<?php 
    echo $this->Html->meta('favicon.ico','/favicon.ico', array('type' => 'icon'));     
?>

回答by Hitesh Chopra

Replace your favicon with app/webroot/favicon.ico and wait for sometime, as it require some time to reflect on browsers.

用 app/webroot/favicon.ico 替换你的 favicon 并等待一段时间,因为它需要一些时间来反映浏览器。

回答by Romain

Check your layout.ctp file to check if your favicon is located at the right place.

检查您的 layout.ctp 文件以检查您的网站图标是否位于正确的位置。

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

使用的大小为 16x16,png 重命名为 .ico

回答by Keyur Padalia

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.

那么你需要从 webroot 目录中删除默认的 favicon.ico 图标文件并放置你自己的图片。但请确保将该图片转换为图标格式并将其重命名为 favicon。我认为它应该起作用,因为它对我有用。