Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Full customization!

Quote Reply
Full customization!
How can I in several category use several templates for links and subcategories? (more than one link.html and category.html)

Quote Reply
Re: Full customization! In reply to
Is this one template per category, or several different templates per category? The answer is different for each.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: Full customization! In reply to
One template per category, but in different category i want use different templates for links and subcategory...

For example:

1. We make category "News"
category template: category.html
subcategory template: subcategory.html
links template: news.html

2. Than we make category "catalog", in which:
category template: category_cat.html
subcategory template: subcategory_cat.html
links template: catalog.html

3. etc...

Is it possible?

Quote Reply
Re: Full customization! In reply to
Template support for different categories is built into links.

This is what the "custom template" field in the category record is for. Create a template for each category. You can alter the style of the header and even the "link" by which files you include.

I'm not sure the category.html template uses a <%loop%> construct, in the 2.04 release or not. If it does, just change the <%include link.html%> to <%include link_category.html%> where category is the category you are in.

I've modified most of my templates to use the <%loop%> construct, and it's not hard. You need to change a couple of routines, so that they send an array_ref back to the template parser, not a string.

Try the "custom template" field first.

I hope in the 2.1 release, Alex has moved most of the link and other looping processes to <%loop%> variables, since it really, really does make things easier, with only minor changes to existing templates, but _SUPER_ potential for the future.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: Full customization! In reply to
You can also enter a 'template directory' into the Custom Template field and then that category page will use a different template directory. For instance, if I put 'yahoo' into the template directory of a ceartain category, it will use the link.html and subcategory.html found in the yahoo directory, not the regular one.

I am looking at implementing loops, just trying to do it with as little template impact as possible.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Full customization! In reply to
In Reply To:
You can also enter a 'template directory' into the Custom Template field and then that category page will use a different template directory. For instance, if I put 'yahoo' into the template directory of a ceartain category, it will use the link.html and subcategory.html found in the yahoo directory, not the regular one.
But you'd have to have a complete template set for each directory, then, not just the category.html and link.html, that's a heck of a lot of duplicated files.... right?



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: Full customization! In reply to
If use <%include template.html%> - no one tags in template.html working :(

We using the method, posted by Alex (Big thanks to U) - and it's worked!

Quote Reply
Re: Full customization! In reply to
May be, in Category properties should be three fields fpr templates?
- CategoryTemplate
- SubCategoryTemplate
- LinksTemplate
I think, it will make customization easier...

Quote Reply
Re: Full customization! In reply to
You missed the <%loop%> portion. You need to have your links, or subcategories sent as an array_ref to the templates, then you use <%loop%> to go through them. Within that <%loop%>...<%endloop%> tag, you'd just change the templates.

You could add a link and subcategory custom field to the category record, but you start expanding fields without a real reason. It becomes a 'hack' when the elegant solution is simply to change the way the links and subcategories are sent to the category.html template (as an array_ref, not a string) and <%loop%> through them.

Using <%loop%> tags, you wouldn't even need the category field at all. If Alex added a test for existence to the template parser, such that:

<%ifexists template.html%>

it would be really, really easy to load the correct template.

If there was a function in the template parser code for:

<%GT::Template::get_category_template%>

That was triggered when a call to site_html_category was made, that

1) got the current category_id
2) checked to see if a template category_id.html existed
3) if not, it generated a list of the parent categories
and checked each parent in turn for a category_id.html (where ID is the parent ID).
4) if it found one, it used that file, if it didn't, it used the default category.html

I'm pretty sure that is a similar process to what is being done now, just with a twist.

Within each category_id.html file, you could call whatever subtemplates you needed to,
and give each category it's own look and feel.

To make it easier, maybe add a link on the "category browser" or category add screens
to create a category_id.html file for that category.

This is not quite human friendly, but it wouldn't be too hard to also add an option
to the edit templates page, "Show custom category templates" and the templates are
listed in a list:

ID - Name

Click on it, to edit it.


What is the benefit of this??

It's one less troublesome field in the Category table. The "display" is moved out
of the database, and into the templates directory. It's one more level of separation
between code/data/display.


BTW: for those who might feel giving such "power" to a list of files, such that the
existence of a category_93.html will change the way that category displays, is somewhat
odd, I should point out that this is how Unix machines boot up.... s and k files, in
numerical order, by numerical directories. If it's good enough for the Unix kernal,
its good enough for my application :) <G>



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin