vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How to use variables created inside a hook (https://vborg.vbsupport.ru/showthread.php?t=92094)

sv1cec 07-13-2005 11:49 AM

How to use variables created inside a hook
 
I have created a hook, attached at location showthread_postbit_create, in showthread.php. The code in the hook does some calculations and returns some values to some variables, let's call them $show1, $show2 etc.

At the end of the hook, I check the variables, by echoing them, and they are correct. However, when I try to use them inside postbit template, they are empty. Is there a specific way to call these variables? I even tried making them global, still no luck.

Rgds and tnx

akanevsky 07-13-2005 02:10 PM

I'd like to know that too.

Marco van Herwaarden 07-14-2005 07:48 AM

Did you use a global before assigning the vaules?

akanevsky 07-14-2005 11:50 AM

Quote:

Did you use a global before assigning the vaules?
Is that required? It would be nice if they did those variables auto-global... Like they are in the templates.

sv1cec 07-15-2005 09:18 AM

Unfortunatelly yes, you have to declare them as global, as I find out.

akanevsky 07-15-2005 10:30 AM

Really? Crap. Well then, it would be IMHO the best to use those variables as $GLOBALS['var']

its less clutter than

global $var;
$var =

Andreas 07-16-2005 01:27 AM

Another possibility:

In the Hook:
$vbulletin->foo = 'bar';

In the Postbit
{$this->registry->foo}


All times are GMT. The time now is 08:52 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.01011 seconds
  • Memory Usage 1,718KB
  • 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_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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