Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

nph-build.cgi: Ignore categories with '@' in them?

Quote Reply
nph-build.cgi: Ignore categories with '@' in them?
Hi all,

I'm currently adding '@' style categories to 'jump' to other sections of my directory, by adding the @ to the end of the category name (so links knows how to group it) and putting a HTML anchor in a new field I added for the purpose. My problem is that links is building a directory page for these categories, e.g.; Shopping and Services/Employment@ ... gets built as ... /Shopping_and_Services/Employment_

Since these '@' cats are not actual pages, I'd like links to skip them when it builds the category pages. In effect I think I'm looking for a way of getting links to look at the last character of the category name when it begins the build process and skip past any pages that have '@' at the end.

Is this easy to do?

All the best
Shaun

Quote Reply
Re: nph-build.cgi: Ignore categories with '@' in them? In reply to
Use a regex, match for /@$/, and if NOT regex, do the page,
otherwise, next.



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: nph-build.cgi: Ignore categories with '@' in them? In reply to
Pugdog,

I'm not really that good at understanding all the mechanics of perl, but how does this look:

Code:
# Skip building if it has '@' in the name
my $skp = $OUT{category_name};
my $find = "@";
if ($skp =~ /$find$/) {next};
I had to set the $find variable simply because I couldn't get @ to work on its own in the if statement.

I'm also a bit unsure of the {next} part. I'm assuming it goes to the next record of the loop, but I'm not 100% sure. I just want to make sure this won't have any detremental effect on the build process!!

Any advice appreciated - thanks.

All the best
Shaun
Quote Reply
Re: nph-build.cgi: Ignore categories with '@' in them? In reply to
That looks about right.... '$skip' is an extra step, it's fine
for clarity, though some would argue it's really not necessary:

Code:
foreach $category_r (@{$categories_r}) {
if ($category_r->{'Name'} =~ /@$/) {
next; ## if the category name ends in @ skip
} else {
do the page build operation
}
}
http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: nph-build.cgi: Ignore categories with '@' in them? In reply to
Pugdog,

All done, thanks for the help Smile

All the best
Shaun