Perrin Harkins wrote:

On Mon, 2005-01-03 at 14:13 -0500, Arshavir Grigorian wrote:


I have a package subroutine that requires an Apache request object and will return a list of privileges (based on a session id stored in pnotes). So I am wondering whether I should be using TT's Plugin interface to make this subroutine accessible from within a template (make it a class), or whether there is a better way for doing this.



I would just get the list of privileges before running the template and pass them in as data.



I thought about that, but it would mean passing this data to every page, then code every page to relay it to the toolbar library template on each include. I would like to avoid doing this especially since almost all the pages need this toolbar.

I was thinking that if I could make the toolbar template a self sufficient component, then the regular pages/templates would just include it and have it do its own thing, instead of having to relay data from their own process calls.

$tt->process('sample_page.html', { data => $data_for_sample_page,
                                  priveleges => [EMAIL PROTECTED] });

sample_page.html
----------------------
[% INCLUDE toolbar $priveleges %]


for each page on the system.


If the Plugin is the way to go, would I have to initialize the Template object to contain a reference to the Apache request object, then use it from within the template that includes the plugin?



If you need a request object in a plugin, just get it by calling
Apache->request(). That will work fine unless you're using threads.


Thanks. This makes sense.

- Perrin





_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to