News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Add Favicon (favories/bookmark icon)

Started by hadesflames, March 09, 2007, 05:03:51 PM

Previous topic - Next topic

FirefoxyChic

Hi all -
Just need some thought about a weird issue concerning favicon support.
I have added the following lines of code to my index.template.php file:
   if ( $enable_favicon  )
         {
      echo '<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />';
      echo '<link rel="icon" href="/favicon.ico" type="image/x-icon" />';
         }

Added it under this section of code in the header:
// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '><head>
<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
<meta name="description" content="', $context['page_title'], '" />', empty($context['robot_no_index']) ? '' : '
<meta name="robots" content="noindex" />', '
<meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/script.js?fin11"></script>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var smf_theme_url = "', $settings['theme_url'], '";
var smf_images_url = "', $settings['images_url'], '";
var smf_scripturl = "', $scripturl, '";
var smf_iso_case_folding = ', $context['server']['iso_case_folding'] ? 'true' : 'false', ';
var smf_charset = "', $context['character_set'], '";
// ]]></script>
<title>', $context['page_title'], '</title>
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css?fin11" />
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?fin11" media="print" />';


I have uploaded the favicon (.ico) file to the main directory as well as the theme directory (just in case), and the icon shows up file in all browsers EXCEPT Safari 4. Now I have done my research and followed the advice to clear Safari's cache, as well as even "resetting" it, and the icon still does NOT show up! And it is not just on my computer, also my client's - he is the one who brought it to my attention. Any thoughts?
It is a mysterious case I know, but there has to be an explanation!
thanks,
Emily G

CesarManara

Language portuguese_brazilian on SMF 1.1.10.

Original translate by: Joomlamz

Modifications.portuguese_brazilian.php
Code (Find) Select
?>
Code (Add Before) Select
$txt['header_favicon_url'] = 'Favicon URL da imagem:';
$txt['header_favicon_url_desc'] = 'Deve estar em 16x16 png/gif/ico imagem
    <br />Utilizar .Ico para a melhor compatibilidade(eg IE7)
    <br />Deixar em branco para desabilitar
    <br />(<a href="http://en.wikipedia.org/wiki/Favicon" target="_blank">Ajuda</a>)';

hadesflames

Thanks for this translation! I have added it to the package =]

Costa

Aldo, forget the previous portuguese translation from Joomlamz
If you want translations for your mods, please PM to me =)

portuguese_pt

$txt['header_favicon_url'] = 'URL da imagem Favicon:';
$txt['header_favicon_url_desc'] = 'Tem que ser uma imagem com 19x19 pixeis e no formato png/gif/ico
<br />Use o formato .ico para uma melhor compatibilidade (ex IE7)
<br />Deixe em branco para desabilitar
<br />(<a href="http://pt.wikipedia.org/wiki/Favicon" target="_blank">Ajuda</a>)';


portuguese_brazilian

$txt['header_favicon_url'] = 'URL da imagem Favicon:';
$txt['header_favicon_url_desc'] = 'Tem que ser uma imagem com 19x19 pixeis e no formato png/gif/ico
<br />Use o formato .ico para uma melhor compatibilidade (ex IE7)
<br />Deixe em branco para desabilitar
<br />(<a href="http://pt.wikipedia.org/wiki/Favicon" target="_blank">Ajuda</a>)';


No changes to UTF-8, and I change the Wikipedia page to the portuguese version =)
Hugo "Costa" Fernandes - PT SMF
Todas as MP's a pedir ajuda são sujeitas a radioactividade, microondas, queimadas e atiradas borda fora.

"At least someone appreciates the fact that I am doing and not thinking..."
"Laziness is counter-revolutionary."

hadesflames

#164
Thanks Costa ^^ Will add them soon =]

edit:

Added

MATTEK

This will not work with the curve color variation themes. Is this something known by the writers or something no one has come across yet? If it's a known issue please let me know how to make it work. Thank you.
SMF 2.0.1

Like Comics, Books, Movies or T.V. Shows? Read about them here!!

hadesflames

You need to apply manual edits to make this work with custom themes. I have explained how to do this in the download page. SMF 2.0 users need to do something more than 1.1 users.

MATTEK

I'm having issues with IE8. Does not work. Chrome, Ie7 and below and Firefox all work fine.
SMF 2.0.1

Like Comics, Books, Movies or T.V. Shows? Read about them here!!

hadesflames

Have you tried putting IE8 in compatibility mode?

Nodaz

I used this mod and it worked like a charm...
BUT i used an animated ico, works in firefox but not in IE 8...
is that typical?
Is there a way yo have both?

airric00

I used this from the download section on 2.0 , now where do I put my icon and does this code need to be altered to allow it show?

QuoteCode: [Select]
'description' => $txt['header_logo_url_desc'],
         'type' => 'text',
      ),
Add after:
Code: [Select]
array(
         'id' => 'header_favicon_url',
         'label' => $txt['header_favicon_url'],
         'description' => $txt['header_favicon_url_desc'],
         'type' => 'text',
      ),
SMF 2.0 ONLY:
In SMF 2.0 you will also have to edit your index.template.php file of the same directory as above, search for:
Code: [Select]
<title>', $context['page_title_html_safe'], '</title>';
add after:
Code: [Select]
// Favicon Edits
   global $context;
   $link_rel = '';
   if (!empty($settings['header_favicon_url']))
   {
      if(preg_match('~http://(?:.*?)\.(png|ico|gif)(?:\?(?:.*?)|)~i', $settings['header_favicon_url'], $type))
      {
         // Append to html headers
         $link_rel .= '
            <link rel="'. (!empty($context['browser']['is_ie']) ? 'shortcut icon' : 'icon' ) .'" href="'. $settings['header_favicon_url'] . '" type="'. (($type[1] == 'ico') ? 'image/vnd.microsoft.icon' : 'image/'.$type[1] ) .'" />';
         unset($type);
      }
     
   }
   echo $link_rel;

hadesflames

Quote from: UbinTook on December 22, 2009, 03:24:58 PM
I used this mod and it worked like a charm...
BUT i used an animated ico, works in firefox but not in IE 8...
is that typical?
Is there a way yo have both?


tbh, I'm surprised it even worked in FireFox, I thought favicons where supposed to be static images =/

@airric00 What exactly are you trying to do?

airric00

Quote from: hadesflames on January 01, 2010, 06:30:44 PM
Quote from: UbinTook on December 22, 2009, 03:24:58 PM
I used this mod and it worked like a charm...
BUT i used an animated ico, works in firefox but not in IE 8...
is that typical?
Is there a way yo have both?


tbh, I'm surprised it even worked in FireFox, I thought favicons where supposed to be static images =/

@airric00 What exactly are you trying to do?

got it to work thanks bro

Bugo

Russian translation:

$txt['header_favicon_url'] = 'Адрес изображения для создания значка сайта:';
$txt['header_favicon_url_desc'] = 'Изображение должно быть размером 16x16 и иметь тип png/gif/ico
<br />Используйте формат .ico для лучшей совместимости (нп с IE7)
<br />Оставьте пустым, чтобы отключить.
<br />(<a href="http://ru.wikipedia.org/wiki/Favicon" target="_blank">Справка</a>)';

hadesflames

Thanks Bugo, I'll add the translation ASAP =]

mariusfv

#175
I install this mod without errors but i don't have the menu because in that place is the menu with another mod "custom copyright" so i don't see the menu because is another menu in that place.
So can someone help me please ?
SMF 1.1.11

P.S Mod is installed without errors !
10x in advance !


Solved:
I didn't read at mod description that :
Find in Settings.template.php:
'description' => $txt['header_logo_url_desc'],
         'type' => 'text',
      ),


Add after:

array(
         'id' => 'header_favicon_url',
         'label' => $txt['header_favicon_url'],
         'description' => $txt['header_favicon_url_desc'],
         'type' => 'text',
      ),


OMG :))

mariusfv

#176
Sorry for double post but why is this error ?

Undefined index: header_favicon_url
.....index.php?action=theme;sa=settings;th=1;sesc

Themes/default/Settings.template.php (settings sub template - eval?)
Line: 115

and

Themes/default/Settings.template.php (settings sub template - eval?)
Line: 116

Please help me to resolve this problem
10x

BTW your mod don't Parse from 1.1 to 1.1.11 and in description is avaible for 1.1.11 etc ....
Someone good coder can resolve me the problem with Undefined index: header_favicon_url pls

hadesflames

Hmm, I don't get any such error on a fresh 2.0. Can you turn off sub template eval and post what the error says after?

Admin > Configuration > Server Settings...
tick  Disable evaluation of templates  click save, then go back to your error log and post what it says.

As for the 1.1 it parses just fine for me on 1.1.11.

Vincent Volmer

Hello,

I think (not for sure) this mod causes a lot of errors in the log. All the errors are referring to line 200 in index.php ( $context['html_headers'] .= ' ) and this is all around line 200:

// Favicon Edits
global $context;
if (!empty($settings['header_favicon_url']))
{
if(preg_match('~http://(?:.*?)\.(png|ico|gif)(?:\?(?:.*?)|)~i', $settings['header_favicon_url'], $type))
{
//***This is line 199 ***// Append to html headers
$context['html_headers'] .= '
<link rel="'. (!empty($context['browser']['is_ie']) ? 'shortcut icon' : 'icon' ) .'" href="'. $settings['header_favicon_url'] . '" type="'. (($type[1] == 'ico') ? 'image/vnd.microsoft.icon' : 'image/'.$type[1] ) .'" />';
unset($type);
}

}


Thanks for any help on this. and... I'm running SMF2.0 RC2
Regards,
Vincent


Some of the errors:
URL http://digiscrap.nl/index.php?action=adpro;sa=v&amp;id=2&amp;l=5&amp;m=0&amp;t=1265555860
8: Undefined index: html_headers
File: /shared/usr/xxxx1234567/DOMAIN/www.digiscrap.nl/HTML/index.php
Line: 200

URL http://digiscrap.nl/index.php?action=adpro;sa=v&amp;id=1&amp;l=8&amp;m=0&amp;t=1265555856
8: Undefined index: html_headers
File: /shared/usr/xxxx1234567/DOMAIN/www.digiscrap.nl/HTML/index.php
Line: 200

URL http://digiscrap.nl/index.php?action=adpro;sa=v&amp;id=3&amp;l=5&amp;m=0&amp;t=1265555832
8: Undefined index: html_headers
File: /shared/usr/xxxx1234567/DOMAIN/www.digiscrap.nl/HTML/index.php
Line: 200

URL http://digiscrap.nl/index.php?action=adpro;sa=v&amp;id=4&amp;l=7&amp;m=0&amp;t=1265555825
8: Undefined index: html_headers
File: /shared/usr/xxxx1234567/DOMAIN/www.digiscrap.nl/HTML/index.php
Line: 200

URL http://digiscrap.nl/index.php?action=adpro;sa=v&amp;id=7&amp;l=1003&amp;m=0&amp;t=1265553176
8: Undefined index: html_headers
File: /shared/usr/wcen7085654/DOMAIN/www.digiscrap.nl/HTML/index.php
Line: 200

Some other errors:

URL http://digiscrap.nl/index.php?action=calendar;sa=post;month=02;year=2010;day=28
8: Undefined index: html_headers
File: /shared/usr/xxxx1234567/DOMAIN/www.digiscrap.nl/HTML/index.php
Line: 200

URL http://digiscrap.nl/index.php?action=dlattach;attach=202;type=avatar
8: Undefined index: html_headers
File: /shared/usr/xxxx1234567/DOMAIN/www.digiscrap.nl/HTML/index.php
Line: 200

URL http://digiscrap.nl/index.php?topic=1460.0
8: Undefined index: html_headers
File: /shared/usr/xxxx1234567/DOMAIN/www.digiscrap.nl/HTML/index.php
Line: 200

Vincent Volmer


Advertisement: