Gossamer Forum
Home : Products : Links 2.0 : Customization :

Category Templates

Quote Reply
Category Templates
Ok guys..this what i wish to do, I have a music site..what I wish to acheive is have a seperate template for the top category and a template for all subcategorys underneath. Say Top category is Blues (template for only Blues) and a seperate template for all subcategory's underneath. So for each top category a seperate template and a seperate template for all subcategory's underneath that top one..had a look at bobsies template mod..ya could do it bit would be there for a month writing if's and else's...is there another way??

Admittedlamb.

Quote Reply
Re: Category Templates In reply to
Doing the following would work:

Add an extra field to your categories.db in this field you'd have the template name you want to use with it. Then in site_html_templates.pl or nph-build.cgi add some code to go thru categories.db and find the corresponding template for each category.

Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Category Templates In reply to
"Add an extra field to your categories.db in this field you'd have the template name you want to use with it. Then in site_html_templates.pl or nph-build.cgi add some code to go thru categories.db and find the corresponding template for each category."

Um yep but no...don't think I explained myself to well. Try again..Have a seperate template for all the top category's...and a seperate template for all the subcategory's underneath, so a seperate template for top category Blues..and a template for all (the same template) for the subcategory's underneath blues.... So is um mainblue.html for Blues and subblue.html for the subcategory's A to Z underneath......mainPOP.html for POP and subPOP.html for subcategory's A to Z underneath POP...Does that better explain what I wish. Or confused it more *grins*.

Admittedlamb>



Quote Reply
Re: Category Templates In reply to
First open category.def and add the field:


Template => [8, 'alpha', 40, 75, 0, '', ''],

Then use an update script to update your category.db (add the extra | onto the end of each record). (if you don't know how to update a db search the forum on it)

Then open the category db in admin or offline. For each category you want to have a different template open the category up and add the template name to this field eg. category1.html


Then open site_html_templates.pl sub site html category and add:


require "$db_lib_path/catgory.def";
open (CATEGORY, "<$db_category_name") or &error ("unable to open category database: $db_category_name. Reason: $!");
while (<CATEGORY>) {

(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
next unless ($category_name eq $data[8]);
%rec = &array_to_hash (0, @data);
last;
}
close CATEGORY;

if ($rec{'Template'}) {
$cattemplate = $rec{'Template'};
}

else {
$cattemplate = "category.html";
}




Replace:


return &load_template ( 'category.html', {


With:


return &load_template ( $cattemplate, {


Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Category Templates In reply to
Here's what you'd do if you wanted to edit nph-build instead (prob more efficient to use this), I've tested it and it works. Back your nph-build up first though! Add the extra field as before and then open nph-build.cg find the sub build_category_pages:

replace
# We set up all the variables people can use in &site_html.pl.
($description, $related, $meta_name, $meta_keywords, $header, $footer) = @{$category{$cat}}[2..7];


Replace it with:



# We set up all the variables people can use in &site_html.pl.
($description, $related, $meta_name, $meta_keywords, $header, $footer, $cat_template) = @{$category{$cat}}[2..8];



Then open site_html_templates.pl in the sub site html category add:




if ($cat_template) {
$cattemplate = $cat_template;
}

else {
$cattemplate = 'category.html';
}




Replace:


return &load_template ( 'category.html', {


With:


return &load_template ( $cattemplate, {

Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Category Templates In reply to
Thanks Glennu..It worked perfectly..Thanks again...and also it showed how to sovle another problem I was working on..and thats to have links build windows media .asx files which i have now also got working..so again thanks..

Admittedlamb.

Quote Reply
Re: Category Templates In reply to
No problem, oh yeah with a few alterations it could also be setup to display different link.html's for each category aswell... Again leaving the Template field blank for a category would mean the default templates are used instead.

Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Category Templates In reply to
Just to let people know I've altered it so that different link.html's can also be assigned to each category. If anyone wants it I'll post brief instructions on how to do it soon.

Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Category Templates In reply to
Hi Glennu,

I think that could be pretty useful!



Until next time...

Ryan

http://links.innovationstudios.com/
Quote Reply
Re: Category Templates In reply to
Yep posted it on my site:

Go here for just multiple categories:

http://cgi-resource.co.uk/pages/multcat.shtml

Go here for instructions for both multiple categories and links

http://cgi-resource.co.uk/pages/multcat2.shtml



Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: [glennu] Category Templates In reply to
hello guys, MOD http://cgi-resource.co.uk/pages/multcat.shtml is great.

when i install it to CLEAR links 2,its work fine.



but im using a L I N K S v 2 . 0 D O W N L O A D A R C H I V E from http://www.nicky.net/

and when im install multicats MOD there, its doesnt working.

please help to install it for my links