From: Paul L. <pa...@sq...> - 2006-11-06 15:51:32
|
On 11/6/06, Paul Lesniewski <pa...@sq...> wrote: > On 11/6/06, Paul Lesniewski <pa...@sq...> wrote: > > > I believe it would be nice to allow plugins to override some template > > > values during the fetch() stage. > > > > > > If I'm not mistaken, the template_construct_<file>.tpl / plugin_output > > > thing is only for making plugins output their own pages, rather than > > > tweak what's already there. Am I right? > > > > Well, add not their own pages -- add additional output information to > > the current template page being fetched, but yeah... however, note > > that the $this value is in fact being passed on that hook. I always > > get it backward, but I think it's in PHP 5, objects are passed by > > reference so you can already reach in and change things in $this on > > that hook. In PHP 4, I wonder if we could make sure that the hook > > function itself passes the args through by reference to the plugins > > themselves. That might be useful in other contexts too anyway and > > might solve some sticky problems with hook return values and make > > modifying plugin hook args in general a lot less painful. > > Didn't even have to do that (again, might be because this is PHP5 I am > testing with). I just passed in the $args to my plugin function (off > of the construct_template_<file> hook) and modified $this like this: > > $args[1]->assign('xxx', 'XXXXXXXXXXX'); > > The "xxx" value came through in the template. > > Anyone care to test on PHP4? > > .... ah wait, I am pretty sure PHP4 will complain, since I got this to > work even when the args in my plugin are not passed by value. (sorry, meant by *reference*) When someone can test in PHP4 (yeah yeah I should get myself a test environment...), the fix might be to simply change this line in functions/plugin.php (line 152 in cvs HEAD): - function concat_hook_function($name,$parm=NULL) { + function concat_hook_function($name,&$parm=NULL) { In which case we should think about changing ALL hook functions in the same way unless there is a good reason not to. Of course, when testing this, make sure the plugin itself is taking the args by reference too. -paul |