Gossamer Forum
Home : Products : Links 2.0 : Customization :

multicat mod problem

Quote Reply
multicat mod problem
http://cgi-resource.co.uk/pages/multcat.shtml

i'm trying to get the Multi Category Templates mod to work -
but it doesn't build the category pages for some reason..

here is the changes I have made....
I hope you can help...


sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.

my $ext = ".html";
if ($cat_template) {
$cattemplate = "$cat_template$ext";
}

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



return &load_template ( $cattemplate, {
date => $date,
time => $time,
category => $category,
links => $links,
title_linked => $title_linked,
title => $title,
total => $total,
grand_total => $grand_total,
category_name => $category_name,
category_name_escaped => $category_name_escaped,
category_clean => $category_clean,
description => $description,
meta_name => $meta_name,
meta_keywords => $meta_keywords,
header => $header,
footer => $footer,
prev => $prev,
next => $next,
related => $related,
build_links_per_page => $build_links_per_page,
%globals
} );
}


Footer => [7, 'alpha', 40, 75, 0, '', ''],
Subcats => [8, 'alpha', 0, 255, 0, '', ''],
Template => [9, 'alpha', 40, 75, 0, '', '']
);


# 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..9];



















Quote Reply
Re: multicat mod problem In reply to
Do you get an error message?

Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: multicat mod problem In reply to
Shouldn't

my $ext = ".html";

just be

$ext = ".html";




Quote Reply
Re: multicat mod problem In reply to
Nope...localizing the variable is not the problem...

What the user should use is:

Code:

$cat_template$build_extension


Since this variable is already defined in the links.cfg file...

Regards,

Eliot Lee
Quote Reply
Re: multicat mod problem In reply to
Then shouldn't this work:


sub site_html_category {
my $template;
if ($cat_template) {
$template = "$cat_template$build_extension"; }
else { $template = "category.html"; }

return &load_template ( $template, {
date => $date,
time => $time,
category => $category,
links => $links,
title_linked => $title_linked,
title => $title,
total => $total,
grand_total => $grand_total,
category_name => $category_name,
category_name_escaped => $category_name_escaped,
category_clean => $category_clean,
description => $description,
meta_name => $meta_name,
meta_keywords => $meta_keywords,
header => $header,
footer => $footer,
prev => $prev,
next => $next,
related => $related,
build_links_per_page => $build_links_per_page,
%globals
} );
}

Quote Reply
Re: multicat mod problem In reply to
Not really, since you do need to define the $cat_template which should be:

Code:

$cat_template = $rec{'Template'};


or whatever you named the TEMPLATE field in the category.def file...

Regards,

Eliot Lee
Quote Reply
Re: multicat mod problem In reply to
do you mean it's ok as it is?
at the moment it doesn't build the category pages...
I can't see an error page because it's a cobalt server and there seems to be a problem showing that page...

Quote Reply
Re: multicat mod problem In reply to
NO, I do not!

READ my reply again!!!!!!! *sigh*

It has zlitch/nada/nothing/ to do with your server's platform or operating system...it has to do with improperly configured Perl codes!

Regards,

Eliot Lee
Quote Reply
Re: multicat mod problem In reply to
I did read it but wasn't sure -

"What the user should use is:
$cat_template$build_extension"

where should this go? what should it replace?



Quote Reply
Re: multicat mod problem In reply to
Uh...those are NOT the codes I was referring to in my later post...please re-read all my replies, because you ain't getting it...Wink

Regards,

Eliot Lee
Quote Reply
Re: multicat mod problem In reply to
so
'$cat_template = $rec{'Template'};' is the only change ?

but where does it go? it isn't very clear with all the cross postings



Quote Reply
Re: multicat mod problem In reply to
Would replacing your site_html_category with this work?

sub site_html_category {
my $template;
$cat_template = $rec{'Template'};
if ($cat_template) {
$template = "$cat_template$build_extension"; }
else { $template = "category.html"; }

return &load_template ( $template, {
date => $date,
time => $time,
category => $category,
links => $links,
title_linked => $title_linked,
title => $title,
total => $total,
grand_total => $grand_total,
category_name => $category_name,
category_name_escaped => $category_name_escaped,
category_clean => $category_clean,
description => $description,
meta_name => $meta_name,
meta_keywords => $meta_keywords,
header => $header,
footer => $footer,
prev => $prev,
next => $next,
related => $related,
build_links_per_page => $build_links_per_page,
%globals
} );
}

Quote Reply
Re: multicat mod problem In reply to
Yea...if you actually have a FIELD in your category.def file called Template and if you have the name of the TEMPLATE file in that field in your categories.db file, then it would work.

Regards,

Eliot Lee
Quote Reply
Re: multicat mod problem In reply to
so if your template file is called business.html

you should have : $cat_business = $rec{Business'}; ?

If you are starting from scratch with an empty categories.db I presume it will build in the extra field?


and in category.def

Business => [9, 'alpha', 40, 75, 0, '', '']




Quote Reply
Re: multicat mod problem In reply to
No...you are missing the point completely!!!

Refer to the MOD instructions again, because you are not getting it...you are missing a bunch of steps...re-install the Mod, start over!

Regards,

Eliot Lee
Quote Reply
Re: multicat mod problem In reply to
can you simply answer me one thing - below is my current setting -
1. is there a problem with it
2. what should be replaced, where and with what

I appreciate your help but my original question is being muddied by other debates... i really only want to know if there is a problem with the code... that's all.




sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.
my $ext = ".html";
if ($cat_template) {
$cattemplate = "$cat_template$ext";
}
else {
$cattemplate = 'category.html';
}
return &load_template ( $cattemplate, {
date => $date,
time => $time,
category => $category,
links => $links,
title_linked => $title_linked,
title => $title,
total => $total,
grand_total => $grand_total,
category_name => $category_name,
category_name_escaped => $category_name_escaped,
category_clean => $category_clean,
description => $description,
meta_name => $meta_name,
meta_keywords => $meta_keywords,
header => $header,
footer => $footer,
prev => $prev,
next => $next,
related => $related,
build_links_per_page => $build_links_per_page,
%globals
} );
}
Footer => [7, 'alpha', 40, 75, 0, '', ''],
Subcats => [8, 'alpha', 0, 255, 0, '', ''],
Template => [9, 'alpha', 40, 75, 0, '', '']
);
# 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..9];


Quote Reply
Re: multicat mod problem In reply to
"1. is there a problem with it"

yeah. it's basically not getting the data for a template field in your category.db.


"2. what should be replaced, where and with what"

Your category.def file would have to have this setup:

# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 500, 0, '', ''],
Related => [3, 'alpha', 0, 255, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 275, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 275, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', ''],
SubCatStyle => [8, 'alpha' ,40, 100, 0, '(ALL)1', ''],
Template => [9, 'alpha', 40, 100, 0, '', '']
);


Then, you REPLACE your site_html_category subroutine with the one below.


sub site_html_category {
my $template;
$cat_template = $rec{'Template'};
if ($cat_template) {
$template = "$cat_template$build_extension."; }
else { $template = "category.html"; }

return &load_template ( $template, {
date => $date,
time => $time,
category => $category,
links => $links,
title_linked => $title_linked,
title => $title,
total => $total,
grand_total => $grand_total,
category_name => $category_name,
category_name_escaped => $category_name_escaped,
category_clean => $category_clean,
description => $description,
meta_name => $meta_name,
meta_keywords => $meta_keywords,
header => $header,
footer => $footer,
prev => $prev,
next => $next,
related => $related,
build_links_per_page => $build_links_per_page,
%globals
} );
}

Then you make a template file and put it into your templates directory. When you add a category via admin, you need to put the name of the template you wish to use for that category in the Template field. So if you have a category named "Rodeo Clowns" and you want to use a specific template for it called rodeo.html, then you would type rodeo in the template field. It should find the template name with the extension (rodeo.html) and build the category page using the correct template -- and if no template name is specified in the Template field when you add a Category, then it should default to category.html

I think that should do it... Isn't that right Eliot?

Quote Reply
Re: multicat mod problem In reply to
It still doesn't seem to be loading the new template file

"sub site_html_category {
my $template;
$cat_template = $rec{'Template'};
if ($cat_template) {
$template = "$cat_template$build_extension."; }
else { $template = "category.html"; }"

is that correct?


this is from nph_build.cgi - does it need to be changed too?

# 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..9];





Quote Reply
Re: multicat mod problem In reply to
'is that correct?'

Nope, it wasn't the way I did it (I tested it out and it worked fine). Use what you originally posted but change:

($description, $related, $meta_name, $meta_keywords, $header, $footer, $cat_template) = @{$category{$cat}}[2..9];

To:

($description, $related, $meta_name, $meta_keywords, $header, $footer, $subcats, $cat_template) = @{$category{$cat}}[2..9];

You can change the build extension to use what's originally defined in links.cfg if you want, like Eliot suggested. Either way it should work fine.



Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml