Version: 1.00, by rukia
Developer Last Online: Oct 2008
Category: Miscellaneous Hacks -
Version: 3.7.x
Rating:
Released: 09-16-2008
Last Update: 09-16-2008
Installs: 10
Re-useable Code Additional Files
No support by the author.
>> Note: This requires Apache & mod rewrite. If you do not have these, I cannot help you. <<
What does it do? This little code snippet and directory setup, combined with mod rewrite will allow you to dynamically generate a favicon for your site based on the user's style preference.
What is required for this to run properly? Apache & mod rewrite. If you do not have these, the mod will not function properly.
Absolutely no change or addition in vBulletin code is necessary.
For those of you who want to skip code addition and upload the files, I've attached the PHP code to the post, however you will need to read on for .htaccess instructions. If you have an existing .htaccess file, please do not delete the existing contents, instead follow the instructions I've provided here. Also, please read the PHP code section and make sure you update the file paths if necessary.
First, create a new file in the root directory of your forum called favicon.php
If you do not know where this is, navigate to vBulletin Options -> Site Name / URL / Contact Details and look at the URL provided for Forum URL. This is the root directory of your forum.
In this new file, you will need to add the following code.
>> NOTE: YOU WILL NEED TO CHANGE THE FILE PATHS FOR THIS TO FUNCTION PROPERLY. <<
To do this, locate /skins/default/misc/favicon.ico
You will need to change this to the misc images directory path of your DEFAULT FORUM SKIN. For example, if the directory path is /images/default/misc/ then you will need to change it to /images/default/misc/favicon.ico
Now, save favicon.php and create a new file in the same directory as this one. We will call this file .htaccess
If you already have a .htaccess file, you will need to make a few additions to it to make sure the PHP code we just added is properly used.
At the top of your .htaccess file, add the following lines.
Code:
RewriteEngine on
RewriteRule favicon.ico favicon.php
If you already have mod rewrite enabled, RewriteEngine on can be omitted from this entry.
Now that we've set up the code and instructed Apache to look at favicon.php for our favicon, we need to set up the directory structure. Note that if you do not have a favicon in all directories, the code will automatically use the favicon from your default skin.
>> Note: You will need to leave favicon.ico in your root directory along with favicon.php. It does not matter what this icon looks like, it merely matters that it exists in the directory for purposes of mod rewrite. <<
Simply locate your /skins/style/misc/ directories, and add your own custom favicon for each one until you are satisfied with them.
Note that the change may not be immediate, depending on your browser. You may have to clear history and/or cache for it to update, and in some cases, it may not update at all, or for awhile even.
This mod is final. No updates will be made except for newer variable names.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
For root/red123, as long as it's in root/red123/misc it should use that URL for the icon. If that's the URL of the default skin and not the others, simply modify the default skin URL to look in $vbulletin->options['bburl'].'/red123/misc/favicon.ico', the script should still then automatically find the icon in any other directory so long as it's in the misc directory and the URL is provided in the style options. Note that it will always look in the root/path to styles/misc/ area, the default URL is the only one that has to be manually specified. I'll see if I can't find a way to locate the URL of the default skin so no modification is required.
Couldn't you do it this method to. The instructions where a little challenging to understand. I got it to work, but this also work.
Upload the generated file ("favicon.ico") to your site. Verify it's there by typing
Code:
http://mysite.com/favicon.ico
in the browser's location, where "
Code:
mysite.com
" is your site's address.
Next, insert the below code in the HEAD section of your pages, at the very least, your site's main index page:
Code:
<link rel="shortcut icon" href="/favicon.ico">
That's it! Note that your favicon may not appear immediately after you've completed the above two steps. In fact, it may take a few days, and in IE, sometimes the favicon will disappear from time to time due to a browser bug.
It showed up immediately after using the alternate method. It doesn't matter where you put the image.
That is a much more simple way to do it, my original concept included something similar. The problem I had with it was that it only affected pages where the HTML was included in the header. If you place it in headinclude, it will be displayed on any page where you print the template, but it won't affect pages that don't make use of vBulletin's template system. With the script and rewrite engine, it enables you to display the favicon anywhere on the site, regardless of header HTML.