Hi,

I have a set of templates that should include a toolbar at the top.
The toolbar is generated based on the user's privileges, hence I am thinking that the toolbar should be its own component which can be included individual templates.


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.
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? Something like this:


my $tt = Template->new({
INCLUDE_PATH => "$cfg{tt_path}:$cfg{tt_lib_path}",
INTERPOLATE => 1,
DEBUG => 1,
COMPILE_DIR => '/tmp/ttc',
COMPILE_EXT => '.ttc2',
PRE_DEFINE => {
RootPathWeb => $cfg{'root_path_web'},
ImagePathWeb => $cfg{'image_path_web'},
CssPathWeb => $cfg{'css_path_web'},
JsPathWeb => $cfg{'js_path_web'},
+ ApacheRequest => $r
},
}) || die MCAM::Exception->Exception("Error creating the template object: ".$Template::ERROR);


toolbar.html
----------------
[% USE Toolbar ($ApacheRequest) %]
[% FOREACH privelege = Toolbar.priveleges %]
...
[% END %]

I am using TT 2.14 with Apache2/mp2.

Thanks in advance for any comments/suggestions.



Arshavir




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

Reply via email to