How to change favicon using head.phtml into a custom theme?
I'm trying this:
file head.phtml into my themes/my_theme/templates/layout but favicon is not working!
- <?php $this->headLink()->prependStylesheet($this->stylesheetSrc('global.css', null, false))?>
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('theme.css', null, true))?>
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('ie-styles.css', null, true), "screen, projection", "lt IE 9")?>
<?php $this->headLink()->headLink(array('rel' => 'favicon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'PREPEND');?>
<?php $this->headLink()->headLink(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'PREPEND');?>
<?php $this->headScript()->offsetSetFile(-100, $this->javascriptSrc('jquery.js', null));?>
<?php $this->headScript()->offsetSetFile(-99, $this->javascriptSrc('application.js', null));?>
<?php $this->headScript()->appendFile($this->javascriptSrc('global.js', null, false))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('scripts.js', null, true))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('ie-script.js', null, true), 'text/javascript', array('conditional' => 'lt IE 9'))?>
<?php echo $this->headTitle() . PHP_EOL ?>
<?php echo $this->headMeta() . PHP_EOL ?>
<?php echo $this->headLink() . PHP_EOL ?>
<?php echo $this->headScript() . PHP_EOL ?>
<?php echo $this->headStyle() . PHP_EOL ?>
Mario, click "Show Source Code" in your browser and take a look what you have there.
Maybe the reason is in wrong path. As I see you have tried to override head.phtml file in your theme folder. Make sure that path to head.phtml is relative to original.
Mario, click "Show Source Code" in your browser and take a look what you have there.
Maybe the reason is in wrong path. As I see you have tried to override head.phtml file in your theme folder. Make sure that path to head.phtml is relative to original.
I've checked paths but all seems to be correct! In fact I'm able to change head.phtml and see variations on source code.
Now I've forced favicon, but I don't like this:
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('theme.css', null, true))?>
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('ie-styles.css', null, true), "screen, projection", "lt IE 9")?>
<?php $this->headLink()->headLink(array('rel' => 'favicon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'APPEND');?>
<?php $this->headLink()->headLink(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'APPEND');?>
<?php $this->headScript()->offsetSetFile(-100, $this->javascriptSrc('jquery.js', null));?>
<?php $this->headScript()->offsetSetFile(-99, $this->javascriptSrc('application.js', null));?>
<?php $this->headScript()->appendFile($this->javascriptSrc('global.js', null, false))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('scripts.js', null, true))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('ie-script.js', null, true), 'text/javascript', array('conditional' => 'lt IE 9'))?>
<?php echo $this->headTitle() . PHP_EOL ?>
<?php echo $this->headMeta() . PHP_EOL ?>
<?php echo $this->headLink() . PHP_EOL ?>
<?php echo '<link rel="shortcut icon" href="'.$this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico').'" type="image/x-icon" />'. PHP_EOL ?>
<?php echo '<link rel="favicon" href="'.$this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico').'" type="image/x-icon" />'. PHP_EOL ?>
<?php echo $this->headScript() . PHP_EOL ?>
<?php echo $this->headStyle() . PHP_EOL ?>
and the final source now looks like
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>useresponse</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link href="http://localhost/useresponse/public/static/1cdc7bd17eb3519a7b8e984d03ab7980_minify.css" media="screen" rel="stylesheet" type="text/css" />
<!--[if lt IE 9]> <link href="http://localhost/useresponse/public/themes/my_theme/assets/css/ie-styles.css" media="screen, projection" rel="stylesheet" type="text/css" /><![endif]-->
<link rel="shortcut icon" href="http://localhost/useresponse/public/themes/my_theme/assets/images/favicon.ico" type="image/x-icon" />
<link rel="favicon" href="http://localhost/useresponse/public/themes/my_theme/assets/images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" ><![endif]-->
<script type="text/javascript">
I've checked paths but all seems to be correct! In fact I'm able to change head.phtml and see variations on source code.
Now I've forced favicon, but I don't like this:
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('theme.css', null, true))?>
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('ie-styles.css', null, true), "screen, projection", "lt IE 9")?>
<?php $this->headLink()->headLink(array('rel' => 'favicon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'APPEND');?>
<?php $this->headLink()->headLink(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'APPEND');?>
<?php $this->headScript()->offsetSetFile(-100, $this->javascriptSrc('jquery.js', null));?>
<?php $this->headScript()->offsetSetFile(-99, $this->javascriptSrc('application.js', null));?>
<?php $this->headScript()->appendFile($this->javascriptSrc('global.js', null, false))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('scripts.js', null, true))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('ie-script.js', null, true), 'text/javascript', array('conditional' => 'lt IE 9'))?>
<?php echo $this->headTitle() . PHP_EOL ?>
<?php echo $this->headMeta() . PHP_EOL ?>
<?php echo $this->headLink() . PHP_EOL ?>
<?php echo '<link rel="shortcut icon" href="'.$this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico').'" type="image/x-icon" />'. PHP_EOL ?>
<?php echo '<link rel="favicon" href="'.$this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico').'" type="image/x-icon" />'. PHP_EOL ?>
<?php echo $this->headScript() . PHP_EOL ?>
<?php echo $this->headStyle() . PHP_EOL ?>
and the final source now looks like
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>useresponse</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link href="http://localhost/useresponse/public/static/1cdc7bd17eb3519a7b8e984d03ab7980_minify.css" media="screen" rel="stylesheet" type="text/css" />
<!--[if lt IE 9]> <link href="http://localhost/useresponse/public/themes/my_theme/assets/css/ie-styles.css" media="screen, projection" rel="stylesheet" type="text/css" /><![endif]-->
<link rel="shortcut icon" href="http://localhost/useresponse/public/themes/my_theme/assets/images/favicon.ico" type="image/x-icon" />
<link rel="favicon" href="http://localhost/useresponse/public/themes/my_theme/assets/images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" ><![endif]-->
<script type="text/javascript">
Mario, I really can't understand what the problem to change favicon.
You simply need to override application/templates/layout/head.phtml by copying to your theme folder as shown on attached image as example.
Then, find the folllowing lines:
and change favicon paths to yours.
To change favicon is as easy as falling off a log.
Mario, I really can't understand what the problem to change favicon.
You simply need to override application/templates/layout/head.phtml by copying to your theme folder as shown on attached image as example.
Then, find the folllowing lines:
and change favicon paths to yours.
To change favicon is as easy as falling off a log.
Exactly what I tried to do, same folders structure! But this is not working for me.
I've just changed head.phtml as you suggested and the tag for favicon is disappeared from home page html source...
No way...
Is it possible that the problem is caused by the fact that I'm trying to put my favicon into the customized theme folder?
$this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'PREPEND');?>
My code now:
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('theme.css', null, true))?>
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('ie-styles.css', null, true), "screen, projection", "lt IE 9")?>
<?php $this->headLink()->headLink(array('rel' => 'favicon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'PREPEND');?>
<?php $this->headLink()->headLink(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'PREPEND');?>
<?php $this->headScript()->offsetSetFile(-100, $this->javascriptSrc('jquery.js', null));?>
<?php $this->headScript()->offsetSetFile(-99, $this->javascriptSrc('application.js', null));?>
<?php $this->headScript()->appendFile($this->javascriptSrc('global.js', null, false))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('scripts.js', null, true))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('ie-script.js', null, true), 'text/javascript', array('conditional' => 'lt IE 9'))?>
<?php echo $this->headTitle() . PHP_EOL ?>
<?php echo $this->headMeta() . PHP_EOL ?>
<?php echo $this->headLink() . PHP_EOL ?>
<?php echo $this->headScript() . PHP_EOL ?>
<?php echo $this->headStyle() . PHP_EOL ?>
Exactly what I tried to do, same folders structure! But this is not working for me.
I've just changed head.phtml as you suggested and the tag for favicon is disappeared from home page html source...
No way...
Is it possible that the problem is caused by the fact that I'm trying to put my favicon into the customized theme folder?
$this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'PREPEND');?>
My code now:
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('theme.css', null, true))?>
<?php $this->headLink()->appendStylesheet($this->stylesheetSrc('ie-styles.css', null, true), "screen, projection", "lt IE 9")?>
<?php $this->headLink()->headLink(array('rel' => 'favicon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'PREPEND');?>
<?php $this->headLink()->headLink(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => $this->baseUrl('/public/themes/my_theme/assets/images/favicon.ico')), 'PREPEND');?>
<?php $this->headScript()->offsetSetFile(-100, $this->javascriptSrc('jquery.js', null));?>
<?php $this->headScript()->offsetSetFile(-99, $this->javascriptSrc('application.js', null));?>
<?php $this->headScript()->appendFile($this->javascriptSrc('global.js', null, false))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('scripts.js', null, true))?>
<?php $this->headScript()->appendFile($this->javascriptSrc('ie-script.js', null, true), 'text/javascript', array('conditional' => 'lt IE 9'))?>
<?php echo $this->headTitle() . PHP_EOL ?>
<?php echo $this->headMeta() . PHP_EOL ?>
<?php echo $this->headLink() . PHP_EOL ?>
<?php echo $this->headScript() . PHP_EOL ?>
<?php echo $this->headStyle() . PHP_EOL ?>
Mario,
Do you see the favicon by link in browser? What is the problem of changing default favicon to yours? Just make sure that after system update you'll need to replace it one more time
Mario,
Do you see the favicon by link in browser? What is the problem of changing default favicon to yours? Just make sure that after system update you'll need to replace it one more time
Maybe browser cache?
One more question: Are you sure that the proper theme was chosen in Administration -> Interface?
Maybe browser cache?
One more question: Are you sure that the proper theme was chosen in Administration -> Interface?
Stas Kuzma wrote:
I'm checking source code of the page and there is notI'm not looking only at the browser output.
And no, My_theme is selected correctly in fact I've changed other things as logo and colors.
Stas Kuzma wrote:
I'm checking source code of the page and there is notI'm not looking only at the browser output.
And no, My_theme is selected correctly in fact I've changed other things as logo and colors.
Your custom theme must be active in interface settings area.
After all changes you are making must also be under the current selected theme.
Your custom theme must be active in interface settings area.
After all changes you are making must also be under the current selected theme.
Replies have been locked on this page!