Gossamer Forum
Home : Products : Links 2.0 : Customization :

Multiple Category templates parent only

Quote Reply
Multiple Category templates parent only
Hi

I have installed the multiple templates mod by bobsie. However I do not want the parent template to apply to sub categories, which is what happens unless you specifically apply templates to the sub categories. This is a bit involved and could cause problems if I modify the sub cats. I know their was a mod by widgetz (at least when I search the forum it is mentioned), but this has dissapeared. Does anyone else know of a method of applying a template to the parent category only.

Thanks

Rob



Quote Reply
Re: Multiple Category templates parent only In reply to
If we analyze the problem, I think we can find a solution. First of all, any category that is not the top level category will contain a / in its name. So, we should be able to eliminate any categories that contain a /.

Second, my mod looks to see if a category name contains a string, starting at the first position. It uses the =~ operators to do that. There is no reason that can not be eq instead.

Let's assume, for example, that you will use the category.html template for formatting of all categories below the top level and you want to use special templates for selected top level categories. Something like this should do the job:
Code:
if ($category_name =~ /\//) {
$template = "category.html";
} elsif ($category_name eq "TopCat1") {
$template = "cat1.html";
} elsif ($category_name eq "TopCat2") {
$template = "cat2.html";
} elsif ($category_name eq "TopCat3") {
$template = "cat3.html";
} else {
$template = "category.html";
}
Is that what you are looking for?

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Multiple Category templates parent only In reply to
That was it. I had tried eq, but I had the format wrong. Thanks for taking the time to explain it too. I may get the hang of this perl programing yet!

Cheers

Rob



Quote Reply
Re: Multiple Category templates parent only In reply to
Hi,
I have tried the code from the Resource center as well as the code in this thread, but hve not been able to make it work.
The current code I'm using is this:
Code:
sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.
###### Multiple Category Templates Mod ####
my $template;
# Set the appropriate template file to load
if ($category_name =~ /\//) {
$template = "category.html"; }
elsif ($category_name eq "Computadoras_y_Tecnologia") {
$template = "tecnologia.html"; }
elsif ($category_name eq "Politica") {
$template = "politica.html"; }
elsif ($category_name eq "Asuntos_Sociales") {
$template = "asuntos_soc.html"; }
else {$template = "category.html"; }
Further down I have this: return &load_template ( $template, {

Did I missed something in the code?

Your help is appreciated.

Regards,
Manuel





Quote Reply
Re: Multiple Category templates parent only In reply to
Can someone help me with this? Smile

Manuel

Quote Reply
Re: Multiple Category templates parent only In reply to
Hi

Here is the section from my site_html_template

my $template;

# Set the appropriate template file to load
if ($category_name eq "Sport") {
$template = "catsport.html"; }
elsif ($category_name =~ /^Comedy\/Comedians/) {
$template = "category.html"; }
elsif ($category_name =~ /^Comedy\/Venues/) {
$template = "category.html"; }
elsif ($category_name =~ /^Comedy/) {
$template = "catcomedy.html"; }
else { $template = "category.html"; }


Try modifying that.

Also, go thro Bobsies instructions really carefully and cross off each modification. Many time, when I have had problems it is because I did not follow exactly what was written

All the best
Rob


Quote Reply
Re: Multiple Category templates parent only In reply to
I went over the code (again). I copy and pasted Bobsie's original code
Code:
my $template;

# Set the appropriate template file to load
if ($category_name =~ /^Category1/) {
$template = "cat1.html"; }
elsif ($category_name =~ /^Category2/) {
$template = "cat2.html"; }
elsif ($category_name =~ /^Category3/) {
$template = "cat3.html"; }
else { $template = "category.html"; }
Then I replace the category names with mine, as follows:
Code:

# Set the appropriate template file to load
if ($category_name =~ /^Computadoras y Tecnologia/) {
$template = "cat_tecnologia.html"; }

elsif ($category_name =~ /^Politica/) {
$template = "cat_politica.html"; }

elsif ($category_name =~ /^Derecho_y_Justicia/) {
$template = "cat_derecho.html"; }

else { $template = "category.html"; }
No results. Nothing happens.
Did i missed somtehing?

Regards,
Manuel

Quote Reply
Re: Multiple Category templates parent only In reply to
Can someone shed some light on this Smile?

Thanks.

Manuel

Quote Reply
Re: Multiple Category templates parent only In reply to
Bobsie:
How can I modify the following code to have the category blahblah and the subcategories of this one use the same template? (blahblah.html) (I am using the Non-English Mod which assumes that the character separating the categories is "\" and not "/"

my $template_name;
if ($category_name =~ "blahblah") {
$template_name = "blahblah.html"; }
elsif...

Sorry, but I am very dumb with perl and I cannot make it by my own :(

Thanks in advance
Shardon

Quote Reply
Re: Multiple Category templates parent only In reply to
Did you create the new template html files and put them in the templates directory? Did you rebuild? The code looks right, so something else must not be right. I assume you made those changes in sub site_html_category of site_html_templates.pl?

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Multiple Category templates parent only In reply to
In Reply To:
How can I modify the following code to have the category blahblah and the subcategories of this one use the same template?
To have a category and all subcategories use the same template, all you need to do is something like this (assuming you have a category called, Computer with multiple subcategories beneath it):
Code:
my $template;
if ($category_name =~ /^Computer/) {
$template = computer.html; }
else
$template = category.html; }
It makes no difference whether or not you use / or \ as the divider in the category names. The part that says /^Computer/ tells Links to find any category/subcategory that starts with Computer and use the computer.html template for those categories.

I hope this helps.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Multiple Category templates parent only In reply to
Thank you for your time bobsie, but it doesn't work. What is I am trying to do, is to use webadverts with 'zoning' banners, and I want all the main category with it's subs to have the same banners loaded. The first category is using the template correctly but when I am reaching the second it shows the ads.pl file that is in category.html...
Is it possible that the problem is I am using the Non-English mod? please, if you can help me, I would really appreciate it

Regards
Shardon

Quote Reply
Re: Multiple Category templates parent only In reply to
Please post the code you are using for the multiple templates. Also, please give me an idea as to how the names of the top-level category and subcategories of it are formed as I am not really familiar with the non-English mod. Thanks.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Multiple Category templates parent only In reply to
Bobsie,
In Reply To:
Did you create the new template html files and put them in the templates directory?
Yes. Al new templates are in the templates directory.

In Reply To:
Did you rebuild?
Yes. I even flush the cache in my computer, just in case...

In Reply To:
I assume you made those changes in sub site_html_category of site_html_templates.pl?
Yes!

Manuel




Quote Reply
Re: Multiple Category templates parent only In reply to
This probably has nothing to do with it but I did note:
In Reply To:
if ($category_name =~ /^Computadoras y Tecnologia/)
Shouldn't there be an underline character instead of spaces on both sides of the y in the category name?

I keep seeing references to a \ character being used for the non-English mod. I assume this is your case as well. Are you sure this is in the category_name field and not another field? What field, if any, uses the / character to create the directory for the category or subcategory?

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Multiple Category templates parent only In reply to
Hi,

I tied out the same, but it doesn't work. Only Markt is fine:

my $cat_template;
# Set the appropriate template file to load
if ($category_name =~ /^Markt/) {
$cat_template = "cat_markt.html"; }
elsif ($category_name =~ /^Category2/) {
$cat_template = "cat2.html"; }
elsif ($category_name eq "FOTO-Galerie") {
$cat_template = "cat_inbau.html"; }
else { $cat_template = "category.html"; }

Any idea?
Chris

Quote Reply
Re: Multiple Category templates parent only In reply to
FOUND IT !!!

I Cannot believe that I can help somebody else for once and I 'm very happy :))

Change the $category_name variable with the $nonenglish variable. Everything works great now for me...

Thank you very much Bobsie, your guidance made me check this out, and I understand that you couldn't help without this mod because you couldn't know the existence of this variable (it haves the value of the non english name). You are the greatest.

Regards, Shardon

Quote Reply
Re: Multiple Category templates parent only In reply to
Bobsie,

In Reply To:
Shouldn't there be an underline character instead of spaces on both sides of the y in the category name?
There is an underline. It was typo when doing the post.

In Reply To:
I keep seeing references to a \ character being used for the non-English mod. I assume this is your case as well.
No, I´m not using the nonenglish mod (yet).

In Reply To:
Are you sure this is in the category_name field and not another field?
Positive! This are main categories, not subcats. If you can, take a look at http://carraizo.net

In Reply To:
What field, if any, uses the / character to create the directory for the category or subcategory?
If i understood your question correctly, I´m using the default ´Category´ field´, for example:
Code:
Category: Computadoras_y_Tecnlogia
Category: Computadoras_y_Tecnlogia/Servicios_de_Internet
Thanks for your attention to my post.

Regards,
Manuel



Quote Reply
Re: Multiple Category templates parent only In reply to
Can you please send me (email attachment) your site_html_templates.pl and a copy of all your category templates so that I can look them over? That code should work!

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Multiple Category templates parent only In reply to
????

Waht is a$nonenglish variable???


Chris

Quote Reply
Re: Multiple Category templates parent only In reply to
In Reply To:
That code should work!
Well, it has not worked for me Frown and believe me, I have read many times the instructions and went over the code. I think it may have to do with some mod, but that's beyond my skills.Smile

Anyway, and though I send you the site_html_templates.pl, I searched again the forum and found a nice code that (until now) is working nicely. I'm referring to this http://gossamer-threads.com/...ew=&sb=&vc=1

A little more of work, but is doing the job!

If you find the answer to the inital problem, i would appreciate the answer from you, as appreciated are your previous comments.

Regards,
Manuel