Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Adding Category Field Problem

Quote Reply
Adding Category Field Problem
I've added several new fields to my category.def file and made the required changes in nph-build.cgi and site_html_templates.pl. I now have fields numbered 0-16 but only the first 12 are functional. The information contained in fields 13,14,15,16 is all being combined into field 13 when I build my pages. The admin shows them as seperate fields and they seem to be properly delimited in the categories.db file.

Is there a limit of 13 fields or did I mess something up or forget to change something?

Thanks for any advice. My changes were as follows:

category.def
-----
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 650, 0, '', ''],
Related => [3, 'alpha', 0, 255, 0, '', ''],
'Meta Title' => [4, 'alpha', '40x3', 200, 0, '', ''],
'Meta Description' => [5, 'alpha', '40x3', 200, 0, '', ''],
'Meta Keywords' => [6, 'alpha', '40x3', 500, 0, '', ''],
'Meta Notes1' => [7, 'alpha', '40x3', 200, 0, '', ''],
'Meta Notes2' => [8, 'alpha', '40x3', 200, 0, '', ''],
'Page Title' => [9, 'alpha', 40, 75, 0, '', ''],
Navigation => [10, 'alpha', '40x3', 500, 0, '', ''],
Comparison => [11, 'alpha', '40x3', 500, 0, '', ''],
EXTRA1 => [12, 'alpha', '40x3', 400, 0, '', ''],
EXTRA2 => [13, 'alpha', '40x3', 400, 0, '', ''],
EXTRA3 => [14, 'alpha', '40x3', 400, 0, '', ''],
EXTRA4 => [15, 'alpha', '40x3', 400, 0, '', ''],
EXTRA5 => [16, 'alpha', '40x3', 400, 0, '', '']
);


nph-build.cgi
-----
local ($description, $related, $meta_title, $meta_description, $meta_keywords, $meta_notes1, $meta_notes2, $page_title, $navigation, $next, $prev, $comparison, $extra1, $extra2, $extra3, $extra4, $extra5);

and

($description, $related, $meta_title, $meta_description, $meta_keywords, $meta_notes1, $meta_notes2, $page_title, $navigation, $comparison, $extra1, $extra2, $extra3, $extra4, $extra5) = @{$category{$cat}}[2..16];


site_html_templates.pl
-----
return &load_template ( 'category.html', {
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_title => $meta_title,
meta_keywords => $meta_keywords,
meta_description => $meta_description,
meta_notes1 => $meta_notes1,
meta_notes2 => $meta_notes2,
page_title => $page_title,
navigation => $navigation,
prev => $prev,
next => $next,
related => $related,
build_links_per_page => $build_links_per_page,
%globals,
comparison => $comparison,
extra1 => $extra1,
extra2 => $extra2,
extra3 => $extra3,
extra4 => $extra4,
extra5 => $extra5
} );
}
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
In the links.def file, add them to the db list:

$db_extra1 => 12, $db_extra2 => 13, etc


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding Category Field Problem In reply to
That looks like it's for addidional links fields, not category fields. My links.def fields are working fine, it's the category.def that i've added to.
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
Oops, sorry... Blush

Well, your other code looks OK, not sure what to tell ya... Gotta run right now, will look closer later.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding Category Field Problem In reply to
I have one additional piece of information that might help diagnose the problem:

The fields that are being combined include the | delimiter in the output. It's as if the delimiter is being ignored.

Example:
Field 13 (EXTRA2) = test13
Field 14 (EXTRA3) = test14
Field 15 (EXTRA4) = test15
Field 16 (EXTRA5) = test16

The template output I'm getting is...
<%extra2%> = test13|test14|test15|test16
<%extra3%> thru <%extra5%> are all blank.
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
Did you put the fields in the globals of site-html_templates.pl? You could try:

extra2 => $extra2,
extra3 => $extra3,
etc.

Or, try renaming the fields in category.def, using all lowecase letters.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding Category Field Problem In reply to
I renamed them all to lowercase and the results are the same.

I added them to the globals list and none of them displayed anymore.

I just deleted field 8 and moved all the others up. Sure enough, I now get another one of the extra fields to display properly. Is there simply a limit of 13 fields in the category table?

Last edited by:

biglion: Jan 5, 2005, 6:56 AM
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
I have not heard of a limit before, and don't see why there would be one. Links.def can have as many fields as you want (I've seen 30+), cat.def should be the same. Are you just trying to bring in some info to print that's specific to each category?


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding Category Field Problem In reply to
It's definitely strange that it doesn't work.

Yes, i'm trying to add some related links, banners, navigation, etc. that will be specific to each category. Originally I was doing that by using endless <%if...%> statements in the category template. Unfortunately that gets pretty cumbersome as the number of categories increases. Adding extra fields to the category.def would have been a nice way to take care of that.
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
Try this in site_html_templates.pl:

sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.
return &load_template ( 'category.html', {
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,
more_cat_pages => $more_cat_pages,
extra1 => ($rec{'extra1'}),
extra2 => ($rec{'extra2'}),
%globals
} );
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding Category Field Problem In reply to
Unfortunately when I make the changes, nothing displays for those fields.
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
okay, how 'bout this...


sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.
my %rec = @_;
my extra1 = ($rec{'extra1'}),
my extra2 = ($rec{'extra2'}),
return &load_template ( 'category.html', {
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,
more_cat_pages => $more_cat_pages,
extra1 => $extra1,
extra2 => $extra2,
%globals
} );
}


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Jan 6, 2005, 10:35 AM
Quote Reply
Re: [PerlFlunkie] Adding Category Field Problem In reply to
That get me the error...

Error including libraries: No such class extra1 at /home/bl/public_html/cgi-bin/links/admin/site_html_templates.pl line 120, near "my extra1"
syntax error at /home/bl/public_html/cgi-bin/links/admin/site_html_templates.pl line 120, near "my extra1 ="
Compilation failed in require at nph-build.cgi line 33.
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
oops... need that scalar:

my $extra1 = ($rec{'extra1'}),


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding Category Field Problem In reply to
Sadly that gets us right back to where we started. The fields are still being combined.
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
Quote:
The admin shows them as seperate fields and they seem to be properly delimited in the categories.db file.


If you had existing entries in the links.db, did you add the new delimeters to them? Each entry should have 17 pipes in it.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding Category Field Problem In reply to
It's categories.db and I'm only using 2 records as a test. Each record has 15 pipes which is correct since before the first field and after the last field do not get delimiters. 15 pipes takes care of my 0-16 numbered fields.
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
I'm currently setting up a site with many mods, and a lot of work in links.db, so that's on my brain (I edit the file directly when experimenting...).

I count 16 pipes:

ID 1 Name 2 Description 3 Related 4 'Meta Title' 5 'Meta Description' 6 'Meta Keywords' 7 'Meta Notes1' 8 'Meta Notes2' 9 'Page Title' 10 Navigation 11 Comparison 12 EXTRA1 13 EXTRA2 14 EXTRA3 15 EXTRA4 16 EXTRA5


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding Category Field Problem In reply to
Blush Sorry, my mistake. You are correct that there should be 16.

I removed one of the fields yesterday so the file I'm working with only has 15 as it should.
Quote Reply
Re: [biglion] Adding Category Field Problem In reply to
I've been busy updating the rest of my site, but I still don't have a solution to my categories problem. I guess i'll make due with 13 categories but if anyone knows a solution I'd be eternally grateful Smile. Thanks.