The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How can I use a variable inside a php file in a custom template?
Hello everyone, I have successfully used a function from a file into a custom template before using this plugin: (thanks to kh99 )
PHP Code:
I have my page cotw_sotw.php which uses the template COTW_SOTW . Inside this template I have {vb:raw cotw_sidemenu} which is another custom template (COTW_SIDEMENU). There is a variable in cotw_sotw.php file that I need to use(register) inside the sidemenu template (COTW_SIDEMENU). How would I go about doing so?? If even possible. Any information anyone might have will be appreciated. Thanks for your time everyone. Best Regards. |
#2
|
|||
|
|||
There's two ways you could do it (that I can think of): put a vB_Template:reRegister() call in cotw_sotw.php where you have the variable set, or make the variable global and add another call to vB_Template:reRegister() (where you have the existing one).
|
#3
|
|||
|
|||
Well here we go...
First thing I tried was calling to pre-register the variables within the page file (sotw_cotw.php). Here is the php file snippe : PHP Code:
Any ideas ?? |
#4
|
|||
|
|||
I think what you have should work, but the PreRegister calls aren't quite right, you need a => between the name and the variable:
PHP Code:
And just for the record, to make the variables global you'd just have to put Code:
global $cotw_sotw_sidemenu_vote, $cotw_sotw_sidemenu_nom; in your function code. |
#5
|
|||
|
|||
Quote:
PHP Code:
|
#6
|
|||
|
|||
Sorry, I can't see what might be wrong. You should only have to register the variables in the template once, it doesn't matter if that template is included in another template. You do, of course, have to register them before the template is rendered, but I can't tell if you're doing that from the code you posted.
|
#7
|
|||
|
|||
OK I just ran a VERY easy test. I made this file ... (Does not get ANY simpler)
PHP Code:
PHP Code:
I bet it's something real simple but I just can't figure it out. |
#8
|
|||
|
|||
What hook locations are you using?
|
#9
|
|||
|
|||
global_start.
--------------- Added [DATE]1313174864[/DATE] at [TIME]1313174864[/TIME] --------------- And this is the plguin I am using to render the sidemenu . PHP Code:
|
#10
|
|||
|
|||
Quote:
Try This: PHP Code:
Plugin Hook: parse_templates Code:
ob_start(); require_once('test.php'); $php_include .= ob_get_contents(); ob_end_clean(); |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|