Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Multiple Detail Templates - by Category

Quote Reply
Multiple Detail Templates - by Category
Hi

I would like to use different detail templates, depending on the category.

So, if Shoes is the cat, use the detailed_shoes.html template, and so on.

Bobsie, over in Links flatfile, had some great code to allow multi-template all kinds of stuff, from multi category templates, to multi link.html, to a variation for multi-template detail pages.

Is this kind of flexibility available in SQL?

I know that you can snag a different category.html from another directory, but I would rather use designated templates (by category) within the same main template directory (as is the case over in Links flatfile) for all category.html, link.html, and detail.html.

If anyone might have any suggestions, I would be most grateful.

Thanks Smile

DT
Quote Reply
Re: [DogTags] Multiple Detail Templates - by Category In reply to
Here is an example of Bobsie's code for Links flatfile. Can something like this work in SQL?

Code:
############ Begin Different Link HTML For Separate Categories Part 1/2 #####
my $template_link;
##### Set the appropriate template file to load
if ($category_name =~ "category1") {
$template_link = "link1.html"; }
elsif ($category_name =~ "categoy2") {
$template_link = "link2.html"; }
##### all other categories use standard link template
else { $template_link = "link_home_category.html"; }
######### End Different Link HTML Per Category Part 1/2 ######

Sorry for the extra post. I just don't get the limited-time edit thing. I often come back to fix this or that in my posts cuz I ain't the most efficient note writer.

Thanks Smile

DT
Quote Reply
Re: [DogTags] Multiple Detail Templates - by Category In reply to
Hi,

I'm not sure if this is what you were thinking, but if you enter 'yahoo' in the Category_Template, then it will pull category.html, link.html, detail.html and subcategory.html from the yahoo template directory, not the normal one.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [DogTags] Multiple Detail Templates - by Category In reply to
If I remember correctly, the links sql code does something like that by default.

If you look in admin/Links/Build.pm, sub build_category, it does this:
Code:
# Figure out the template set to use.
$category->{Category_Template} ||= $cat_db->template_set ($category->{ID});
which is a call to sub template_set in Category.pm
This checks the Category_Template field for a template to use for that particular category, or it will use its parent's template.

I'm just starting to tinker with Links SQL (writing the PHP frontend), so I could be wrong Wink.

You might want to check out the new Links SQL manual for something like this.

Adrian
Quote Reply
Re: [Alex] Multiple Detail Templates - by Category In reply to
Thanks, Alex and brewt

I think I get you. Create template directories and name them for the categories. Then, just specify that category group of templates.

Okay, I guess it was right under my noze...

BTW, where is the new Links SQL manual? I still haven't found the old one (unless that is the one in the Help section of the script).

Many thanks Smile

DT

Last edited by:

DogTags: Sep 26, 2001, 12:18 PM