vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   random banner code - what am I doing wrong? (https://vborg.vbsupport.ru/showthread.php?t=285485)

Lpspider 07-12-2012 11:03 PM

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.

kh99 07-12-2012 11:50 PM

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}.

Lpspider 07-13-2012 12:22 AM

Thank you very much for the help. Got it working. :D

GOJOHNNYGO 10-12-2012 01:10 PM

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}. ?

Lynne 10-12-2012 02:58 PM

Quote:

Originally Posted by GOJOHNNYGO (Post 2372526)
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

GOJOHNNYGO 10-12-2012 03:49 PM

Thanks!

GOJOHNNYGO 01-02-2013 09:49 PM

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?

kh99 01-02-2013 10:00 PM

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.

ForceHSS 01-02-2013 10:00 PM

dam just posted about the double >> but was beat to it

GOJOHNNYGO 01-02-2013 11:28 PM

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

Using VB4 if that helps


All times are GMT. The time now is 10:27 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00992 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete