Gossamer Forum
Quote Reply
Plugin-Template-Question
CoolWow, i just wrote my first plugin...and it works...except of a little template-problem:

i've integrated a file myemail.txt into the template and it is correctly installed

into my default template-set, let's call it "mytemplate".



in my mynewplugin.pm i have the following code to parse the myemail.txt -template and to replace some <%vars%>:




use GT::Template;

my $body = GT::Template->parse('verifymail_msg.txt', { error_msg => $msgerror , ID => $msgid , Title => $msgtitle , URL => $msgurl } );




(that's of course not the complete code)

The problem now is I always get an error :


GT::Template::Parser (12006): Unable to locate template file 'myemail.txt' in '/var/www/cgi-bin/xxx/admin/templates/default' or any inheritance directories at /var/www/cgi-bin/xxx/admin/GT/Template/Parser.pm line 100.




Does anyone knows what the problem is and how to get rid of this error (except of installing the myemail.txt into the "default"-template ??

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] Plugin-Template-Question In reply to
From the docs (GT::Template)

Code:
# Parse a string in $template and replace <%key%> with 'value'.
print GT::Template->parse('stringname', { key => 'value' }, { string => $template });

# Compress output of template, print it as it is parsed, not after entirely parsed.
GT::Template->parse_print('file.txt', { key => 'value' }, { compress => 1 });

# Don't display warnings on invalid keys.
print GT::Template->parse('file.txt', { key => 'value' }, { strict => 0 });

# Create a template object using custom settings.
my $obj = new GT::Template({
root => '/path/to/templates',
compress => 0,
strict => 0,
begin => '<!',
end => '!>'
});
my $replace = {
a => 'b',
c => 'd',
e => 'f'
};

$obj->parse_print('file2.txt', $replace);
Look for the 'root' parameter!

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Plugin-Template-Question In reply to
   

hi and thanks for your help,

i had seen that in the GT::Template docs, but somehow i was to stupid to check, that this was what i needed.

But now it works:




use GT::Template;

my $tmplroot = $CFG->{admin_root_path}."/templates/".$CFG->{build_default_tpl};

my $body = GT::Template->parse('verifymail_msg.txt', { error_msg => $msgerror , ID => $msgid , Title => $msgtitle , URL => $msgurl } , {root => $tmplroot});





Thank you very much again.

Now my first version of my first Plugin works fine!

(VerifyMail-Plugin to send Alert-eMails in case of nph-verify.cgi found an error).

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.