PDA

View Full Version : How do you make a custom variable available to other templates?


StephenKay
05-23-2008, 07:59 PM
I have a plug-in attached to the global_complete hook, and it is fetching a custom template and filling it with data, i.e.:

eval('$myvariable .= "' . fetch_template('mytemplate') . '";');

If I echo it to the screen right after the above is called (inside the same plug-in), it works fine - the template is displayed on the page at the top.

However, I want to reference $myvariable inside the FORUMHOME template so that I can have it displayed in a certain location on the page. All of my attempts to do this have failed.

I think I should be able to just put $myvariable into FORUMHOME, but obviously the variable is not available to that when it is called, because nothing is displayed.

$myvariable is declared outside of any functions in the plug-in, so it's not being scope-limited there.

What do I need to do to have $myvariable be available to other templates?

Or, perhaps I'm not calling this in the right place, but I tried other hooks such as forumhome_start, and it still only works when echoed inside the plug-in.

--------------- Added 1211578137 at 1211578137 ---------------

Nevermind - it was my error, in the order of the functions I was calling in the plug-in. It works now as I expected.