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-28-2010, 09:01 AM
Retal Retal is offline
 
Join Date: Nov 2006
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Can't access variables in the advertisment HTML

I want to generate a random number and use it in the ad HTML to rotate banners, but I can't find the right hook to do it.

In a plugin (which one?!)
PHP Code:
$rotate_banner rand(0,1); 
In the Ad HTML:
HTML Code:
<vb:if condition="$rotate_banner">banner.gif</vb:else>...</vb:if>
Tried to use declare the variable as global, add it to $show, $vbulletin, but to no avail.

Anoyne has any idea?
Reply With Quote
  #2  
Old 07-29-2010, 09:26 AM
Retal Retal is offline
 
Join Date: Nov 2006
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dammit, I found the solution in an older plugin of mine; I already solved this before.

For future reference

PHP Code:
$array['rotate_banner'] = rand(1,4);
vB_Template::preRegister('ad_global_below_navbar'$array); 
at the hook global_bootstrap_complete

Change the template name according to the ad position.
Reply With Quote
  #3  
Old 08-02-2010, 04:35 PM
Retal Retal is offline
 
Join Date: Nov 2006
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This drives me crazy.
At my test installation, the variable is preregistered alright.
At the live instance, the variable is not preregistered and I can't access it from the template ad_global_below_navbar.

The plugin is the same. The ad code is the same. But it just doesn't preregister on the live installation.
Do you have any ideas why?
Reply With Quote
  #4  
Old 08-02-2010, 07:27 PM
Guest190829
Guest
 
Posts: n/a
Default

Can we see all of the code in question, it seems like the logic in your first and second posts are different (defining a dynamic boolean in the former and not in the latter).
Reply With Quote
  #5  
Old 08-04-2010, 10:23 AM
Retal Retal is offline
 
Join Date: Nov 2006
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Danny, thanks.
I modified it a bit between the posts.

Plugin at global_bootstrap_complete
PHP Code:
$array['rotation'] = rand(1,2);
vB_Template::preRegister('ad_global_below_navbar'$array); 
Template ad_global_below_navbar
Code:
<!-- rotation: {vb:raw rotation} -->
<object width="234" height="60">
    <param name="movie" value="example<vb:if condition="$rotation == 2">-2</vb:if>.swf">
    <param name="wmode" value="opaque" />
    <param name="allowScriptAccess" value="always">
  <embed src="example<vb:if condition="$rotation == 2">-2</vb:if>.swf" width="234" height="60" allowScriptAccess="always" wmode="opaque"></embed>
</object>
The var $rotation doesn't show at all.
Reply With Quote
  #6  
Old 08-04-2010, 10:47 AM
Guest190829
Guest
 
Posts: n/a
Default

I think it is the hook location that is causing the problem, have tried one of the global_ hooks? global_start or global_setup_complete ?
Reply With Quote
  #7  
Old 08-04-2010, 12:42 PM
Retal Retal is offline
 
Join Date: Nov 2006
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh my, thank you Danny for the kick in the ass! After playing around with it, I found that the hook cache_templates works just fine.
It's still a mystery to me why it works on the test installation and not on the live one, but that is probably due to a different configuration and plugins.

Thanks a lot.
Reply With Quote
  #8  
Old 08-04-2010, 01:04 PM
Guest190829
Guest
 
Posts: n/a
Default

I'm curious too, is your test installation running the same version?
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 09:20 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.03964 seconds
  • Memory Usage 2,223KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_html
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (5)postbit_onlinestatus
  • (8)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