Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

passing globals to plugin template

Quote Reply
passing globals to plugin template
Ok -- so I have a plugin that parses a custom template. How do I pass in the globals set so they are accessable/parsed in the template?

Code:

sub handle_add {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'handle_add'
# is run. You should call GT::Plugins->action ( STOP ) if you don't
# want the regular code to run, otherwise the code will continue as
# normal.
#
my (@args) = @_;
# Do something useful here
# my $p = (ref $_[0] eq 'HASH') ? shift : {@_};

if ($args[0] == undef){
use GT::Template;
my $msgtitle = "test";
my $tmplroot = $CFG->{admin_root_path}."/templates/".$CFG->{build_default_tpl};
my $body = GT::Template->parse('add_start.html', { Title => $msgtitle } , {root => $tmplroot});
print $IN->header;
print "$body";
print Dumper(\@args); GT::Plugins->action ( STOP );

} else {
print $IN->header;
print Dumper(\@args);
return @args;
}
}
Quote Reply
Re: [Swaylock] passing globals to plugin template In reply to
doh! Figured it out my self.

use GT:: siteHTML parse instead..

Code:

use Links::SiteHTML;
my $body = Links::SiteHTML::display( 'add_start', );