Gossamer Forum
Home : Gossamer Threads Inc. : Discussion :

Re: [jaspercram] include a filename which is stored in a variable

Quote Reply
Re: [jaspercram] include a filename which is stored in a variable In reply to
For the record, I would use the template global generate_tmplname to generate the template name if it exists:
Code:
sub {
my $tags = GT::Template->tags;
my $tmplname = @_[0] || $tags->{do};
my $filename = $tags->{admin_root_path} . "/templates/" . $tags->{template} .
"/" . $tags->{db} . "/$tmplname" . ".html";
return -e $filename ? $filename : "";
}

In my template, I would like to use the subroutine like this:
Code:
<%set actionfile = generate_tmplname('actionlist')%>
<%if actionfile %>
<%include $actionfile%>
<%elsif%>
<%include default.html%>
<%endif%>

This would show a table specific template if it exists and a default template otherwise. Really useful!!!!!!Cool

Jasper

BTW I am not sure how DBMan SQL specific the code above is. Sorry...

http://www.bookings.org
Subject Author Views Date
Thread include a filename which is stored in a variable jaspercram 15051 Nov 15, 2002, 3:05 AM
Thread Re: [jaspercram] include a filename which is stored in a variable
yogi 14881 Nov 15, 2002, 3:18 AM
Post Re: [yogi] include a filename which is stored in a variable
jaspercram 14763 Nov 15, 2002, 3:25 AM
Post Re: [jaspercram] include a filename which is stored in a variable
Paul 14776 Nov 15, 2002, 4:23 AM
Thread Re: [jaspercram] include a filename which is stored in a variable
jaspercram 14766 Nov 15, 2002, 5:18 AM
Thread Re: [jaspercram] include a filename which is stored in a variable
Alex 14765 Nov 15, 2002, 10:38 AM
Thread Re: [Alex] include a filename which is stored in a variable
jaspercram 14731 Nov 18, 2002, 12:25 AM
Thread Re: [jaspercram] include a filename which is stored in a variable
carfac 14678 Nov 21, 2002, 10:46 AM
Thread Re: [carfac] include a filename which is stored in a variable
jaspercram 14653 Nov 21, 2002, 1:16 PM
Post Re: [jaspercram] include a filename which is stored in a variable
carfac 14598 Nov 21, 2002, 1:38 PM
Thread Re: [Alex] include a filename which is stored in a variable
Peter544 14382 May 17, 2003, 4:49 PM
Thread Re: [Peter544] include a filename which is stored in a variable
yogi 14306 May 17, 2003, 11:24 PM
Post Post deleted by Peter544
Peter544 14191 May 18, 2003, 5:37 PM
Thread Re: [yogi] include a filename which is stored in a variable
Peter544 14317 May 19, 2003, 9:47 PM
Thread Re: [Peter544] include a filename which is stored in a variable
Andy 14256 May 20, 2003, 1:25 AM
Thread Re: [Andy] include a filename which is stored in a variable
vicos2 14040 Jun 28, 2003, 6:46 PM
Thread Re: [vicos2] include a filename which is stored in a variable
Alex 14087 Jun 30, 2003, 11:44 AM
Post Re: [Alex] include a filename which is stored in a variable
jai 13205 Feb 28, 2006, 11:25 PM