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

Can I do this with a global

Quote Reply
Can I do this with a global
I'm trying to do a dynamic include (<%include thistempfile.html%>) of a template file inside a template during the build process.

I currently have code like this inside the category template and it works

Code:

<%if category_name eq 'catA'%><%include thisAtemplate.html%><%endif%>
<%if category_name eq 'catB'%><%include thisBtemplate.html%><%endif%>
<%if category_name eq 'catC'%><%include thisCtemplate.html%><%endif%>


I want to add a new field (IncludeTemplate) on the Category file which will contain the name of the template I want to include.

Can I do this with a global? If so, what would the global look like, since I haven't gotten it to work yet.

tia,
-devnick
Quote Reply
Re: [devnick] Can I do this with a global In reply to
I'd recommend doing this in a global. Something like this should work;

<%your_global_name($IncludeTemplate)%>

Code:
sub {
my $tpl_name = $_[0];
if (!$tpl_name) { return; }
return Links::SiteHTML::display($tpl_name);
}

This is untested, but should work Smile

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Can I do this with a global In reply to
Andy,

Thanks a lot!! it worked. Smile

I failed the first time, but I got it now. I had the name of the template (thistemplate.html) in the field on the category file. I'm guessing that SiteHTML appends .html to the end of the field value, because the first time did the build I had fatal errors. I removed the .html from the value and I got it to work.

-devnick
Quote Reply
Re: [devnick] Can I do this with a global In reply to
Glad its working :)

Quote:
I failed the first time, but I got it now. I had the name of the template (thistemplate.html) in the field on the category file. I'm guessing that SiteHTML appends .html to the end of the field value, because the first time did the build I had fatal errors. I removed the .html from the value and I got it to work.

Yeah, Links::SiteHTML::display doesn't require an extension (it assumes .html). There are downsides to this, but that is where GT::Template comes in useful =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!