Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-12-2012, 11:03 PM
Lpspider Lpspider is offline
 
Join Date: Oct 2005
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default random banner code - what am I doing wrong?

I found some code on another forum that's supposed to show a random banner within vbulletin. People posting in the thread got it to work, but I'm stuggling. If someone wouldn't mind taking a look and telling me what I'm doing wrong, I'd greatly appreciate it.

I created a new plugin, with the hook location of "global_start" with this code:

Code:
$banner[1] = "<center><a href=\"http://advertiser-edit.com/?utm_source=website.org&utm_medium=banner&utm_campaign=websiteleaderboard\"><img src=\"http://www.website.org/leaderboard_books_design.jpg\"></a></center>"; 
$banner[2] = "<center> 
<script type=\"text/javascript\"><!-- 
google_ad_client = \"ca-pub-numbersremoved\"; 
google_ad_slot = \"4591232780\"; 
google_ad_width = 728; 
google_ad_height = 90; 
//--> 
</script> 
<script type=\"text/javascript\" 
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\"> 
</script></center>"; 

$rotator = rand(1, 2); 

$bannerrotator = $banner[$rotator];
I've tried placing $bannerrotator in the bottom of the navbar template and also in the ad location in the ads section, but neither work. Instead I get "$bannerrotator" where the ad should appear. What am I doing wrong?

Thanks guys.
Reply With Quote
  #2  
Old 07-12-2012, 11:50 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem is that that was intended for vb3. But it should work in vb4 with a few changes. First, use hook parse_templates. Next, add the following line to the end of the plugin code (for the navbar template):
Code:
vB_Template::preRegister('navbar', array('bannerrotator' => $bannerrotator));

Then in the navbar template, use {vb:raw bannerrotator}.
Reply With Quote
2 благодарности(ей) от:
Liff, Lynne
  #3  
Old 07-13-2012, 12:22 AM
Lpspider Lpspider is offline
 
Join Date: Oct 2005
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much for the help. Got it working.
Reply With Quote
  #4  
Old 10-12-2012, 01:10 PM
GOJOHNNYGO GOJOHNNYGO is offline
 
Join Date: Oct 2012
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am having the same trouble. Total noob question...

When you say the navbar template, where do I find this to insert the {vb:raw bannerrotator}. ?
Reply With Quote
  #5  
Old 10-12-2012, 02:58 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by GOJOHNNYGO View Post
I am having the same trouble. Total noob question...

When you say the navbar template, where do I find this to insert the {vb:raw bannerrotator}. ?
Admincp > Styles & Templates > Style Manager > find style > Edit Templates
Reply With Quote
  #6  
Old 10-12-2012, 03:49 PM
GOJOHNNYGO GOJOHNNYGO is offline
 
Join Date: Oct 2012
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks!
Reply With Quote
  #7  
Old 01-02-2013, 09:49 PM
GOJOHNNYGO GOJOHNNYGO is offline
 
Join Date: Oct 2012
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, I have yet to get this to work properly. I posted this code:

$banner[1] = "<a href="http://bham-jk.com/showthread.php?1015-Meet-N-Mod-Party" target="_blank"><img src="http://i93.photobucket.com/albums/l72/JOHNNYP4409/MeetNModparty_zps9e808cc0.jpg" border="0" alt="MeetnModParty"/></a>";
$banner[2] = "<a href="http://www.tntaccessoriesnservicecenter.com/" target="_blank"><img src="http://i93.photobucket.com/albums/l72/JOHNNYP4409/TNTBannerBlack.png" border="0" alt="TNTaccessories"></a>>";

$rotator = rand(1, 2);

$bannerrotator = $banner[$rotator];

vB_Template:: preRegister('navbar', array('bannerrotator' => $bannerrotator));

Then put this in the "ad_global_below_navbar" template:

{vb:raw bannerrotator}

Then I get this error:
Parse error: syntax error, unexpected T_STRING in /home/bhamjk/public_html/includes/class_bootstrap.php(430) : eval()'d code on line 1

So, what have I done wrong?
Reply With Quote
  #8  
Old 01-02-2013, 10:00 PM
ForceHSS ForceHSS is offline
 
Join Date: Apr 2008
Posts: 6,357
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

dam just posted about the double >> but was beat to it
Reply With Quote
  #9  
Old 01-02-2013, 10:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem is that you've put double quotes around strings that contained double quotes, so they're mismatched. If you use single quotes instead it should work, like:

Code:
$banner[1] = '<a href="http://bham-jk.com/showthread.php?1015-Meet-N-Mod-Party" target="_blank"><img src="http://i93.photobucket.com/albums/l72/JOHNNYP4409/MeetNModparty_zps9e808cc0.jpg" border="0" alt="MeetnModParty"/></a>';
$banner[2] = '<a href="http://www.tntaccessoriesnservicecenter.com/" target="_blank"><img src="http://i93.photobucket.com/albums/l72/JOHNNYP4409/TNTBannerBlack.png" border="0" alt="TNTaccessories"></a>>';

$rotator = rand(1, 2);

$bannerrotator = $banner[$rotator];

vB_Template:: preRegister('navbar', array('bannerrotator' => $bannerrotator));

Also I noticed that the $banner[2] string has >> at the end, I don't know if that's a typo or not.
Reply With Quote
  #10  
Old 01-02-2013, 11:28 PM
GOJOHNNYGO GOJOHNNYGO is offline
 
Join Date: Oct 2012
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks guys. I got those fixed. Not showing any errors now, but the banner still doesn't show up.

Using VB4 if that helps
Reply With Quote
Reply


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 03:20 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.04922 seconds
  • Memory Usage 2,255KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (2)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete