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

Different detail template for each category?

Quote Reply
Different detail template for each category?
Hi thereSmile

I just want to know if there is a way to use a different detail template for certain categories?

Thanks


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Different detail template for each category? In reply to
Sure, should be able to (its not that simple though)

1) Add a new field in your glinks_Category table, for example DetailedPageTemplateName (CHAR/255)
2) Then add this global:

work_out_what_detailed_template
Code:
sub {
my $cat_id = $DB->table('CatLinks')->select( ['CategoryID'], { LinkID => $_[0] } )->fetchrow;
my $template = $DB->table('Category')->select( ['DetailedPageTemplateName '], { ID => $cat_id } )->fetchrow;
$template ? return { DetailedPageTemplateName => $template } : return { DetailedPageTemplateName => "" };
}


3) Then, in detailed.html - use:

Code:
<%work_out_what_detailed_template($ID)%>
<%if DetailedPageTemplateName%>
<%include $DetailedPageTemplateName%>
<%else%>
..show normal code from detailed.html here , i.e generic detailed page
<%endif%>

Should work =)

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] Different detail template for each category? In reply to
Hmmm.... makes sense. Thanks Andy. I'll give it a try later today and let you know.


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Different detail template for each category? In reply to
Thanks Andy, that method worked 100% great. Laugh


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Different detail template for each category? In reply to
Cool, good to hear =)

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] Different detail template for each category? In reply to
Hi there,

I got new requirements for this solution. Each of the detail templates must be located in their own directories under "admin/templates/luna/local/".
For a test, I created a directory "admin/templates/luna/local/blue", moved "blue_detailed.html" into it, and updated the Category field "DetailedPageTemplateName" to "blue/blue_detailed.html".

Now, when I build the pages, I receive the following error:

Code:
Error: Can't load included file 'blue/newblue_detailed.html': Invalid characters in filename
Any ideas regarding this?


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Different detail template for each category? In reply to
For security purposes, a variable include (<%include $foo%>) cannot contain a path. If you do the proper checking, then you can write a global to do the include. Search the forums, there's code out there for that.

Adrian
Quote Reply
Re: [brewt] Different detail template for each category? In reply to
Ok thanks,

I'll look around.


Sacrifice is not about what you lose,
it is about what you gain in the process.