Add Favicon (favories/bookmark icon)

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

Previous topic - Next topic

hadesflames

Link to Modification


Package Information

Latest Version: 1.3
Original Developer: ccbtimewiz
Current Developer: hadesflames
Built for: SMF 1.1.x - SMF 2.0 RC3
Package: Favicon


What is a favicon? 



A favicon (short for favorites icon), also known as a website icon, or shortcut icon, is an icon associated with a particular website or webpage. A web designer can create such an icon and install it into a website (or webpage) by several means, and most graphical web browsers will then make use of it. Browsers that provide favicon support typically display a page's favicon in the browser's URL bar and next to the page's name in a list of bookmarks. Browsers that support a tabbed document interface typically show a page's favicon next to the page's title. The Microsoft Windows Shell uses favicons to represent "Internet shortcuts" to web pages. - Wikipedia


What does this mod do?

This mod allows you to add a favicon which appears in your address bar, bookmarks (and tabs also in some browsers) through your Current Theme settings.

Favicons are supported by most MODERN browsers. Note, however IE7 only seems to support .ico files. IE6 only supports favicons on bookmarks.

Note you need to create your own favicon for this to work.


For Custom Themes

This modification currently edits a template file called Settings.template.php. A good number of themes have their own Settings.template.php file in their folder, meaning that you won't see the settings for this mod unless you manually put them there.

First check Admin > Current Theme after installing this mod on your theme. If the options are missing, then you most likely have to the manual instructions for the Settings.template.php file.

To do such, open ./Themes/{your_theme}/Settings.template.php by downloading the file from your server using FTP (Refer to: How do I use FTP? / What is FTP?) and make the following edits. Then reupload through the same method.

Find:
'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',
),


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:
<title>', $context['page_title_html_safe'], '</title>';

add after:
// 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;


and you should be good to go ;)

Alteration Log

Version 1.3

[!] Added Support for SMF 2.0 RC1.2 - SMF 2.0 RC2
[!] Added Support for Brazilian Portuguese
[!] Added Support for Spanish

Version 1.2

[!] Re-released on October 1, 2008 by ccbtimewiz
[!] Released on December 1, 2007 by karlbenson


Need Help?

If you need help with this modification, please don't hesitate to post in the support thread.

For more information, reference to the guide that ccbtimewiz made:

[HOW TO] Add a favicon (bookmark/favorite icon) to your forum

RoarinRow

glad there's a mod for this.  I'm been manually updating my index.template.php files for all my available themes.  this will make it easier for everyone else.

SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

WhatsUp

As I have to mod the file for things like Google Webmaster and Google Analytics, I do favicon at the same time, so there is no point in this mod for me.
History Hunters: http://historyhuntersinternational.org/
Enter: test/test
SMF and TinyPortal

DOOM666

i add this to my them like its says to and it wont give me the option to but my icon in anywere

im use the helios the with 1.1.2

choloman05

Didn't work for me. ??

qd-race

#5
I'm still using 1.1 RC3 with SMF 1.0.9 and 1.1 RC3-1 Security Patch and don't work for me either. It saids:

The package you are trying to download or install is either corrupt or not compatible with this version of SMF.

Do I need to mod manually? Please help.
http://www.qd-race.com |  http://www.replica2u.com  |  http://www.steamyx.net

qd-race

I already manually moded but the icon don't show eventhough pointed correctly in Admin->Current Theme Setting
http://www.qd-race.com |  http://www.replica2u.com  |  http://www.steamyx.net

nitins60

Working for me 1.1.2 thanx

Pegasys

I installed this mod, couldn't get it to work even though the code looks like it should... and finally uninstalled it. I don't think the average user is going to be changing their favicon very often, so I don't see this as a "must-have" mod anyway. Sorry...

In fairness, I suspect that the issue(s) I and many others here were having were related to the file path. Absolute paths (ie the full http://yourdomain.com/forum/whatever...) don't seem to work. And with a relative path, you need to know what it's relative to. (ie.. /forum/icon.ico or /images/icon.ico or...??)


In another topic, Kirby suggested the following line of code:

<link rel="shortcut icon" href="', $settings['images_url'] ,'/favicon.ico" />

... to be added to the header section of the index.template.php file for each of your themes. Then, copy your favicon.ico file into the images folder for each theme.

This DOES work quite well. The addition of the " $settings['images_url']  " takes the mystery out of the relative path by setting it to image folder of whatever theme is in use.

** For me, simply copying (or replacing) your favicon.ico file to your domain root folder is all that was required to have the icon show up in the address window/bar and Favorites/Bookmarks of both  IE 6 & Firefox 2. But the code line above was required to have your favicon used in the tabs of Firefox.


*** In theory, the above method would allow you to use a different favicon.ico for each theme. It would only show in the tabs, I believe... but could still be interesting   ;D

choloman05

I think this is an excellent idea for a mod and something that many will enjoy.

@ _Pegasus:  That line of code to be added to the index.template.php does the same thing as this mod, but also eliminates the "relative path" issue?

Quote** For me, simply copying (or replacing) your favicon.ico file to your domain root folder is all that was required to have the icon show up in the address window/bar and Favorites/Bookmarks of both  IE 6 & Firefox 2. But the code line above was required to have your favicon used in the tabs of Firefox.

That last part has me confused. Do you mean that the line of code (above), in addition to this mod lets the favicons show up in the FF tabs?  Thanks!


NativePages

#10
I installed it, and it installed ok. I did the code copy/paste into index.template. I even tried adding the link rel line. I put my favicon image up there in ico, gif, and png formats. I already had it in my root directory.  Someone had told me (when it was only in my root directory) they could see it when they pulled up my site.

I can't. And now it fails on every file on the uninstall test. How do I get rid of it, because now I'm getting this:

First line is subs-package.php 1901, last line is 1909, repeated error (see next code box) on 1901, 1905 and 1908 on

$fp = fopen($filename, 'r+');
if (!$fp && !$trash)
{
// We should have package_chmod()'d them before, no?!
trigger_error('package_flush_cache(): some files are still not writable', E_USER_WARNING);
return;
}
fclose($fp);
}


Error log entries relevant to above:

http://www.nativepages.com/tnindian/index.php?action=packages;sa=uninstall;package=favicon_v1.0.zip 
2: fclose(): supplied argument is not a valid stream resource
File: /home/nativep/public_html/tnindian/Sources/Subs-Package.php
Line: 1908

http://www.nativepages.com/tnindian/index.php?action=packages;sa=uninstall;package=favicon_v1.0.zip 
2: fopen(/home/nativep/public_html/tnindian/Themes/default/../babylon/index.template.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied
File: /home/nativep/public_html/tnindian/Sources/Subs-Package.php
Line: 1901

http://www.nativepages.com/tnindian/index.php?action=packages;sa=install2;package=favicon_v1.0.zip 
512: package_flush_cache(): some files are still not writable
File: /home/nativep/public_html/tnindian/Sources/Subs-Package.php
Line: 1905


http://www.nativepages.com/tnindian
I came, I saw, I installed, I asked a million questions, but eventually I got it!

Pegasys

#11
Quote from: choloman05 on March 12, 2007, 11:04:00 AM
@ _Pegasus:  That line of code to be added to the index.template.php does the same thing as this mod, but also eliminates the "relative path" issue?

Yes. Just adding that one line of code... and also replacing the default favicon.ico in the domain's root folder, does everything that this mod is supposed to do. Except, of course, allow you to set or change the name & type of the favicon in your admin panel. However, if you are going to change your favicon, you will have to upload/FTP the new file to your site anyway. And as long as the new favicon file has the same name, etc, it will be used automatically without and need to change code or settings in your admin panel. So I don't really see the use for this mod.

I supose it might be helpful to those who only use the default theme and are not comfortable manually editing the index.template.php file to add that single line of code. But its also one more setting in the database that has to be continually read-in... and who needs that minor bit of overhead if not neccessary?


Quote
That last part has me confused. Do you mean that the line of code (above), in addition to this mod lets the favicons show up in the FF tabs?  Thanks!

No, I couldn't get this mod to work so I uninstalled it. Just that single code line added to the index.temeplate.php should get the icon to show in the FF2 tabs. At least, that's what it took for me to finally get the FF tabs to show the icon.

Its quite possible that different solutions are required for different hosts as all hosts do things differently. Its also possible that this mod was tested and works fine on all hosts that are set up similarly to the mod author's host. That would explain why it apparently does not work for so many others.


* We do know that IE 6 defaults to looking for a favicon.ico in the root folder of the domain. It uses this favicon to display in the Favorites and the address box/bar.

* Firefox 2 also seems to use the root folder favicon for its address bar and Bookmarks. But not the tabs.

* On my host, a default favicon.ico file of the host's logo was already installed in the domian root folder. Yet, even when I replaced it with a custom icon for my website, FF2 still displayed the host's default icon on the tabs. I'm not sure where FF2 was getting it from. But adding that single line of code apparently over-rode whatever default FF2 was using and my site icon finally displayed in the FF2 tabs.


choloman05

I see now. Thanks very much for all the useful info _Pegasus. 


Pegasys

Quote from: NativePages on March 12, 2007, 06:52:51 PM
I installed it, and it installed ok. I did the code copy/paste into index.template. I even tried adding the link rel line. I put my favicon image up there in ico, gif, and png formats. I already had it in my root directory.  Someone had told me (when it was only in my root directory) they could see it when they pulled up my site.

I can't. And now it fails on every file on the uninstall test. How do I get rid of it, because now I'm getting this:


I'm glad to see that your site is functioning fine now... so I assume you either got the mod working or uninstalled it successfully.

For me, when I visit your site now:

1. There is no favicon at all in IE 6... either in the address window or when the page is added to the Favorites.
* IE 6 can only use icons (.ico). Make sure there is a favicon.ico in your domain's root folder. If there already is, then I don't know why it doesn't show in IE 6.

2. Your custom favicon works perfectly in Firefox 2. It appears on the tab & in the address window... and also shows in the Bookmarks when the page is book marked.


manudevil

Install is OK. I can add the favicon URL in the admin. It adds the code lines in the templates. But nothing appears on the generated HTML code, and I cannot see any favicon.
I added the correct line code manually after uninstalling this mod. Sorry.

NativePages

Quote from: Pegasys on March 13, 2007, 11:04:35 AM
I'm glad to see that your site is functioning fine now... so I assume you either got the mod working or uninstalled it successfully.

For me, when I visit your site now:

1. There is no favicon at all in IE 6... either in the address window or when the page is added to the Favorites.
* IE 6 can only use icons (.ico). Make sure there is a favicon.ico in your domain's root folder. If there already is, then I don't know why it doesn't show in IE 6.
2. Your custom favicon works perfectly in Firefox 2. It appears on the tab & in the address window... and also shows in the Bookmarks when the page is book marked.

I didn't do anything to it. Didn't try to go ahead with the uninstall because of the test failures on the files. It's just sitting there. Evidently when it installed, it did not install the place on my admin panel to add a favicon url or anything. 

I'm not sure why the icon is appearing for some folks and not others, but it's up there in each directory three times as .ico, .png, and .gif.

Weird.  
http://www.nativepages.com/tnindian
I came, I saw, I installed, I asked a million questions, but eventually I got it!

Pegasys

Quote from: NativePages on March 13, 2007, 09:30:18 PM
I didn't do anything to it. Didn't try to go ahead with the uninstall because of the test failures on the files. It's just sitting there. Evidently when it installed, it did not install the place on my admin panel to add a favicon url or anything. 

I'm not sure why the icon is appearing for some folks and not others, but it's up there in each directory three times as .ico, .png, and .gif.

Weird. 

Does your site allow members to choose between two or more themes?  Like almost all mods, this mod only installs to the default theme. (and the Babylon theme, I believe) After installing, if you are not using the default theme, you will not see the extra data fields in your admin panel. This also might explain why some members can see it while others can not.

That being said, when I visited your site, the theme was definately not the default. And as I mentioned before, the favicon worked perfectly for me using FF2... but not at all using IE 6. So that sorta blows away any theory being suggested in the first paragraph, dudn't it?   :D


* I'd be a bit concerned about having the mod installed and not having it pass the tests, or being functional. You might want to think about backing up the files it installs to, then trying the uninstall feature. Either that, or manually edit out the mod. 

karlbenson

If you use a gif or a png icon it will not work in iE6.  IE6 only supports ico icons.

Yes, this mod installs on Default, Classic and Babylon themes.

For any other theme you need to manually install it.

khoking

I just create a favicon and upload it to my public html folder via ftp, then the favicon AUTOMATICALLY appear on my browser URL and bookmark.

Why do we need a mod for favicon?
Kho King
www.ShaShinKi.com
www.PentaxWorld.com

karlbenson

For several reasons
its not always picked up on all servers.
You might not be allowed to upload to the base url.

Advertisement: