Gossamer Forum
Home : Products : Links 2.0 : Customization :

Adding a New Category Field - Problem

Quote Reply
Adding a New Category Field - Problem
I've added a new field (number 8) to my category.def file called "Page". This is to include the page title when the category pages are built:

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

When I then go ahead and put this new Page variable on the category.html template using:

<%Page%>

I get the error of Unkown Tag: Page on all of the category pages when rebuilding the index.

Is there something I am doing wrong here? Maybe I need to modify something else in addition to the category.def page to incorporate the new Page field?

Any help on insight on this would be much appreciated!

--Frank
Quote Reply
Re: Adding a New Category Field - Problem In reply to
No need to add Page as a new field, you can use header field for the same thing.



------------------
Joker
Concepts 2000 Online
www.concepts2000.com
tech@concepts2000.com

Quote Reply
Re: Adding a New Category Field - Problem In reply to
Thanks very much for the detailed explanation on the various coding required to add the category field. That's exactly what I needed since I already use the header and footer fields for headers and footers on my category pages...
Quote Reply
Re: Adding a New Category Field - Problem In reply to
In sub build_category_pages (nph-build.cgi) you are going to need to change:

Code:
# 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];

to read:

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

Finally, in sub site_html_category of site_html_templates.pl, include Page => $page, in the list of variables being passed to the category.html template. That should fix the problem.

However, if you are not using the header field of the category record for anything, then Joker's suggestion requires less coding. You just need to use <%header%> in the category.html... all the other code is already in place.

I hope this helps.
Quote Reply
Re: Adding a New Category Field - Problem In reply to
The FAQ for adding fields in the Resource Center is for the links database. This one is for the category database, so it couldn't just be appended to the other one. Also, it only really applies to the category pages (one subroutine and/or one template).

There hasn't been a lot of questions about adding fields to the category database so I am not so sure this would qualify as a FAQ to begin with since the term, frequently, is not appropriate.

I will keep it in mind though and write up a FAQ for it if the number of help requests for this action increases. Thanks for the suggestion.
Quote Reply
Re: Adding a New Category Field - Problem In reply to
Bobsie,
Would you please consider appending this to the FAQ posting, "Adding Fields" or perhaps a different example since page is not really a a good example.

I think it would reduce questions and help people.

Thanks
Jeff
Quote Reply
Re: [JWells] Adding a New Category Field - Problem In reply to
Again, I'm new so take it easy on me.
I don't want to add a new field to the links2 category database.

Here's the best way I can describe what I want:

If category db looks like 1|Dolls/Porcelain_Dolls|.... etc, then the resulting directory structure of the site
will look like /Dolls and /Dolls/Porcelain_Dolls

I want a <%variable%> for use on the category.html page that corresponds to the "directory" of the page I'm currently viewing.

Therefore, if I'm at /Dolls/index.html the variable would be = Dolls

if I'm at /Dolls/Porcelain_Dolls/index.html the variable would be = Porcelain_Dolls



Is there an fairly easy way to make this mod to the links2 script?

Category_name works when I'm at /Dolls/index.html, BUT

when I'm at /Dolls/Porcelain_Dolls/index.html the category name is Dolls/Porcelain_Dolls --- here I need to lose the Dolls/ portion of the category_name value.......
-----------------------------------------------------------
Professional Search Engine Marketing by Position Concepts Professional Consulting in SEM, SEO and PPC.
Quote Reply
Re: [poscon] Adding a New Category Field - Problem In reply to
Possibly something based on this, from nph-build.pl:


sub build_linked_title {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my $input = shift;
my (@dirs, $dir, $output, $path, $last);

@dirs = split (/\//, $input);
$last = &build_clean(pop @dirs);

$output = qq| <A HREF="$build_root_url/">Top</A> :|;
foreach $dir (@dirs) {
$path .= "/$dir";
$dir = &build_clean ($dir);
$output .= qq| <A HREF="$build_root_url$path/">$dir</A> :|;
}
$output .= " $last";

return $output;
}



In a linked title (breadcrumb), the $last is unlinked, so this is pulling out the last subcategory from the rest of the structure. Just what are wanting to do with this info? That may help with other ideas...


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding a New Category Field - Problem In reply to
PerlFlunkie,
I appreciate all the code, but I'm not a Perl programmer and need to minimize any changes I try to make to the scripts. I can't read Perl very well, but it appears you knida understand what I need.

All I want is a <%variable%> for use on the category.html page that corresponds to the "directory" of the page I'm currently viewing.

Could you do this with the code:

- remove everything except the part that builds the variable (no building of links and html, etc.). Keep it SUPER simple.

- then, tell me specifically where I have to make changes in the .pl, .cgi, .cfg, etc files/


thanks
-----------------------------------------------------------
Professional Search Engine Marketing by Position Concepts Professional Consulting in SEM, SEO and PPC.
Quote Reply
Re: [poscon] Adding a New Category Field - Problem In reply to
I'm a hit n miss hacker, but maybe this will do it. put this in the nph-build.pl towards the bottom, and then add variable => $variable to the top of site_html_templates.pl in the globals, then put the <%variable%> where you want it. Maybe...

sub build_variable {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my $input = shift;
my (@dirs, $dir, $output, $path, $last);

@dirs = split (/\//, $input);
$var = &build_clean(pop @dirs);

foreach $dir (@dirs) {
$path .= "/$dir";
$dir = &build_clean ($dir);
}
$output .= " $var";

return $output;
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [poscon] Adding a New Category Field - Problem In reply to
PerlFlunkie

Wouldn't it be variable => $var ?????????

And if it is supposed to be variable => $var, I used directory => $var and it doesn't seem to work.

The <%directory%> on the category template returns a blank????????

More help please......
-----------------------------------------------------------
Professional Search Engine Marketing by Position Concepts Professional Consulting in SEM, SEO and PPC.
Quote Reply
Re: [poscon] Adding a New Category Field - Problem In reply to
Forgot to change one thing, see the red:

sub build_variable {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my $input = shift;
my (@dirs, $dir, $output, $path, $var);

@dirs = split (/\//, $input);
$var = &build_clean(pop @dirs);

foreach $dir (@dirs) {
$path .= "/$dir";
$dir = &build_clean ($dir);
}
$output .= " $var";

return $output;
}

The variable => $variable tells the script that when it sees tag <%variable%>, to look for the sub that will create the info it needs there. And it looks for the sub name (variable), not anything in the sub ($var). Try again with the above change, maybe that'll do it...


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding a New Category Field - Problem In reply to
???????

The variable => $variable tells the script that when it sees tag <%variable%>, to look for the sub that will create the info it needs there. And it looks for the sub name (variable), not anything in the sub ($var). Try again with the above change, maybe that'll do it...

I'm slow, so should the global be:

directory => $variable OR

directory => $var OR

directory => $directory ???????????
-----------------------------------------------------------
Professional Search Engine Marketing by Position Concepts Professional Consulting in SEM, SEO and PPC.
Quote Reply
Re: [poscon] Adding a New Category Field - Problem In reply to
It should be

variable => $variable

called using

<%variable%>

If you want it to be named 'directory' then change every instance of variable to directory in the code you have changed. The name does not matter, as long as they're all the same.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Adding a New Category Field - Problem In reply to
Still no deal... it's always blank... What the heck is going on?

------------- in site_html_templates.pl, I have --------------
variable => $variable,



------------- in nph_build, I have --------------
sub build_variable {
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my $input = shift;
my (@dirs, $dir, $output, $path, $var);

@dirs = split (/\//, $input);
$var = &build_clean(pop @dirs);

foreach $dir (@dirs) {
$path .= "/$dir";
$dir = &build_clean ($dir);
}
$output .= " $var";

return $output;
}



------------- in category.html, I have --------------
<%variable%>
-----------------------------------------------------------
Professional Search Engine Marketing by Position Concepts Professional Consulting in SEM, SEO and PPC.
Quote Reply
Re: [poscon] Adding a New Category Field - Problem In reply to
I'm no expert on Links 2 any more (been over a year since I *really* played with the codes), but give this new site_html_templates.pl mod a go (attached).

You should have a new tag called <%short_title%> in category.html then.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Adding a New Category Field - Problem In reply to
SmileA BIG THANKS to Andy, PerlFlunkie and Chaz ---- with their help, I have actually solved the problem!

Guys, I can't thank you enough for all the help you provided. Not understanding Perl, I'm sure I'll find myself in a pickle again real soon, but with support like you guys have provided I probably be able to get through the next issue too.

Again, I sincerely appreciate you all's (Texas twang) help!

poscon
Jim
-----------------------------------------------------------
Professional Search Engine Marketing by Position Concepts Professional Consulting in SEM, SEO and PPC.
Quote Reply
Re: [poscon] Adding a New Category Field - Problem In reply to
Well, glad you managed to find a way to do what ya want! I was not testing what I posted, so my replies were limited in their usefulness. Nothing like working with a problem to solve it, instead of trying to do it "hands-off." We're all here to help each other, and sometimes what one says will spark something somewhere else, so even our mistakes are useful. Your gratitude is appreciated!!Smile

I may look into using that hack myself, but of course I'll want it to use the nonenglish mod, too...Wink


Leonard
aka PerlFlunkie