![]() |
Fetching a custom template within a function
PHP Code:
How would I go about calling my custom template from this function? |
<a href="https://vborg.vbsupport.ru/showthread.php?t=119933&highlight=fetch+custom+tem plate" target="_blank">https://vborg.vbsupport.ru/showt...ustom+template</a>
That should help. |
Quote:
Something else of note: if I take the code out of the function and call it inline, the custom template works fine. Maybe that helps... |
Turns out that 'myheader' worked in the function. The problem was that 'myheader' contains references to vB's default header template (as '$header'), and that wasn't working within the function. To get around this, I have to manually call eval('$header = "' . fetch_template('header') . '";'); within the function.
This brings me to my new question: I have some plugin code in the global_start hook that works fine, unless I call it from within a function. How would I go about doing this? |
If you want to access variable define outside a function you need to use the global keyword to enable it to work inside the function. For example:
PHP Code:
|
No need for the colon (does it even work that way?), it should be simply:
PHP Code:
|
Oops my bad. Wasn't concentrating. :p
|
Thanks! A new challenge, though...
I'm now trying to fetch $myheader through a parse_templates plugin, so I no longer have to include that line in my function: PHP Code:
|
Use var_dump and dump the variable to see if it exists.
|
All times are GMT. The time now is 02:16 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|