View Single Post
  #4  
Old 12-18-2007, 03:03 AM
theOZer's Avatar
theOZer theOZer is offline
 
Join Date: Mar 2007
Location: Colorado, USA
Posts: 212
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Random Banners, How I Did It.

Thanks to vB.org, Thread Thumbnails for the banner on/off user option spin-off, other similar threads on vB.org & vB.com/forums.

That I know of this hack works in 3.6.8 PL2 and 3.7.0 Beta 2.

I use the stock vBulletin templates.

For the header area I use a GIF size height of 88. I display 2 animated GIFs, a 710x88 GIF and a 88x88 GIF. This seems to comfortably fits in the header for screen resolutions of 1024x768 or greater. Simply don't display the 2nd banner if you have only one banner. You have around 800 for the width size.

This hack displays GIFs. Change .gif to .jpg (or, .png, .jpeg, .whatever) in the $YourPrefix_randombanner line if needed. FTP your GIFs to your your_vb_forumname/images/misc directory. [Note: $stylevar[imgdir_misc] points to that directory. (I found that in the vB manual.)]

You could call the 3 lines of plugin code $x, $y, $z. But, I suggest: To insure you don't bang heads with vB uniqueify your plugin code. Replace "YourPrefix_" with whatever you wish. For example, Using the prefix "OMAC_" helps me later find changes in my templates and elsewhere.

Because some forum members are still on dial-up I also give forum members the options to turn off the animated banner display. It cuts down on load times for them. If you don't add a User Profile Field just remove the <if condition="$bbuserinfo['fieldXX'] <> 'Off'"> if clause.

In the $YourPrefix_banners line add the names of your banner files. Using an array allows you an unlimited number of banners possible. My example has 4 randomized banners. Yes, you will need to edit/change the plugin if you want to add or remove banners. Smolly.

>>>Add the plugin:

ACP > Plugins & Products > Add New Plugin.

Hook: global_start

Title: Random Banners

Plugin PHP Code:
$YourPrefix_banners=array('thisbannername', 'thatbannername', 'anotherbannername', 'whatever');
$YourPrefix_shuffle=$YourPrefix_banners[rand(0,count($YourPrefix_banners)-1)];
$YourPrefix_randombanner="<img src=\"$stylevar[imgdir_misc]/$YourPrefix_shuffle.gif\" border=\"0\" alt=\"\">\n";

Plugin is Active:
YES

>>>Make the following changes in each style you wish to add the banner to.

ACP > Styles & Templates > Style Manager, select a template, click on All Style Options GO, then under Common Templates, header.

---vB3.6.8 PL2:

find/replace

<td align="$stylevar[right]">
&nbsp;
</td>

with

<td align="$stylevar[right]">
<if condition="$bbuserinfo['field10'] <> 'Off'">
$YourPrefix_randombanner <!-- randomized banner -->
<img src="$stylevar[imgdir_misc]/Your_GIF_filename_Here.gif" border="0" /> <!-- the 2nd, non-randomized banner on OMAC-->
<else />
&nbsp;
</if>
</td>

---vB3.7.0 Beta2:

find/replace

<if condition="$ad_location['ad_header_logo']">$ad_location[ad_header_logo]<else />&nbsp;</if>

with

<if condition="$ad_location['ad_header_logo']">$ad_location[ad_header_logo]
<else />
<if condition="$bbuserinfo['fieldXX'] <> 'Off'"> <!-- Use Banner User Profile Field number, eg, field8 -->
$YourPrefix_randombanner <!-- randomized banner -->
<img src="$stylevar[imgdir_misc]/Your_GIF_filename_Here.gif" border="0" /> <!-- the 2nd, non-randomized banner on OMAC-->
<else />
&nbsp;
</if>
</if>

>>>Add a user option to turn the banner On or Off.

ACP > User Profile Fields > Add New User Profile Field.

Select "single selection radio buttons"

Title: "Banners"

Description: "Turn the banner display On or Off."

In Options, enter "On" and "Off".

Skip down to Display Page and choose "Options: Other". This puts the option under Miscellaneous Options.
Note the field number assigned. Check for this field number in the if statement <if condition="$bbuserinfo['fieldXX'] <> 'Off'"> .
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01178 seconds
  • Memory Usage 1,777KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete