The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Variable works fine in postbit, but is empty in template called from postbit.
hey,
I'm trying to do something from within the postbit that is basically: if condition 1, display template 1, if condition 2, display template 2, etc.. I need to be able to work with the typical postbit variables from within template 1 and template 2. Right now I have a custom template, "postbit_test", that I'm calling from within the postbit template, but I can't get postbit variables to show up inside it. the variable $post[field2] shows up just fine in the postbit template, for example, but it's empty and displays nothing from within "postbit_test". I've tried $GLOBALS[post][field2] with various permutations of parentheses but that isn't doing me much good either. How do I go about calling these variables? I'm going to be attempting to do this with as many templates as possible so any information on how to pass these variables will be very helpful. I'm on vb 3.8 for the record. thank you. |
#2
|
||||
|
||||
How are you calling postbit_test? Is this through a plugin? What hook are you using? Have you looked up the hook in the code and seen if it might be within a function?
|
#3
|
|||
|
|||
I'm calling postbit_test via this "parse_templates" hook
PHP Code:
and then just referencing $postbit_test from within the postbit template. Apparently I should be specifying which variables I want to pass before I make the call? I found this post which seems straightforward enough for a string and a custom variable. Do you know if vB variables will work similarly, or if there's a better way I should be doing it? I'm pretty much going to want the whole $post array available inside postbit_test, and probably $threadinfo and whatever else, too. edit: nvm, I just tested and $threadinfo already works fine inside postbit_test edit 2: actually, I lied, I reference $GLOBALS[postbit_test] within the postbit template |
#4
|
|||
|
|||
The parse_templates hook is called once during initialization. If you want to use $post in something that's displayed in each postbit, you probably want to use hook postbit_display_complete.
|
Благодарность от: | ||
Lynne |
#5
|
|||
|
|||
shit, son. Okay, sweet.
I moved the eval from parse_templates to postbit_display_complete. I had to change $GLOBALS[postbit_test] to a plain $postbit_test inside the postbit template to display anything, but now I've got my postbit_test template showing up as normal, and the $post variables I was trying to reference are now working inside that template instead of empty. Awesome. however, I can't reference $threadinfo variables any more, like I normally can from within postbit, and like I could before I changed the hook location. I'm trying to make use of this functionality, also. Any insight? |
Благодарность от: | ||
TheLastSuperman |
#6
|
|||
|
|||
That hook is called inside a function (construct_postbit() in includes/class_postbit.php, if you want to look at the code), so you need to declare any global variables you want to use. But in the case of the thread info, there is a $thread variable there already.
|
Благодарность от: | ||
Lynne |
#7
|
|||
|
|||
lol. Whoops. Yeah, okay. The $thread variable suits my needs for now, guess I'll just worry about the rest next time I run into the issue. Thanks though!
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|