vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Can't access variables in the advertisment HTML (https://vborg.vbsupport.ru/showthread.php?t=247458)

Retal 07-28-2010 09:01 AM

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?

Retal 07-29-2010 09:26 AM

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.

Retal 08-02-2010 04:35 PM

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?

Guest190829 08-02-2010 07:27 PM

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

Retal 08-04-2010 10:23 AM

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.

Guest190829 08-04-2010 10:47 AM

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 ?

Retal 08-04-2010 12:42 PM

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.

Guest190829 08-04-2010 01:04 PM

I'm curious too, is your test installation running the same version?


All times are GMT. The time now is 12:04 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.01079 seconds
  • Memory Usage 1,728KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete