Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.7 > vBulletin 3.7 Add-ons
Dynamic Favicon Details »»
Dynamic Favicon
Version: 1.00, by rukia rukia is offline
Developer Last Online: Oct 2008 Show Printable Version Email this Page

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

PHP Code:
<?php
require_once('global.php');
$favicon = (file_exists(".{$stylevar['imgdir_misc']}/favicon.ico") ? $vbulletin->options['bburl'].$stylevar['imgdir_misc'].'/favicon.ico' $vbulletin->options['bburl'].'/skins/default/misc/favicon.ico');
$ico = @file_get_contents($favicon);
header("Content-Type: image/x-icon");
echo 
$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.

Comments
  #2  
Old 09-17-2008, 01:14 AM
FreshFroot's Avatar
FreshFroot FreshFroot is offline
 
Join Date: Jul 2005
Posts: 770
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Interesting hack.

Will have to save and take a look.
Reply With Quote
  #3  
Old 09-17-2008, 02:03 AM
dtv100 dtv100 is offline
 
Join Date: Apr 2007
Location: in the south of the north
Posts: 307
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok so if I have 2 skin one is in root/red123 and the other one is in root/images/style/red321

how the links should be then in both step?

thanks for share .
Reply With Quote
  #4  
Old 09-17-2008, 08:24 AM
rukia rukia is offline
 
Join Date: Aug 2008
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 09-26-2008, 11:07 AM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
  1. 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.
  2. 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">
  3. 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.
Reply With Quote
  #6  
Old 09-29-2008, 03:22 PM
rukia rukia is offline
 
Join Date: Aug 2008
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:48 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07580 seconds
  • Memory Usage 2,253KB
  • Queries Executed 19 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete