Gossamer Forum
Home : Products : Links 2.0 : Customization :

creating hidden category or 2nd database...?

Quote Reply
creating hidden category or 2nd database...?
I am creating a portal style web site and would like to have an additional category that users can add links to but I do not want this category to display with all of the others on the Home Page.

I was wondering if a category can be added to the database that is somehow excluded from the normal category search or if there is a way to implement a second database to hold this additional category.

All help is greatly appreciated!
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
You can exclude a category quite easily, actually. In nph-build.cgi, go to sub build_category_pages. Right after the following code:

Code:
# Go through each category and build the appropriate page.
CATEGORY: foreach $cat (sort keys %category) {
next CATEGORY if ($cat =~ /^\s*$/); # How'd that get in here? =)
next CATEGORY if ($build_single and ($build_single ne $cat));

add the following line, changing "category_to_exclude" to the name of the category to exclude:

Code:
next CATEGORY if ($cat =~ "category_to_exclude");

Now Links will not build the category page for that category. However, the category will still show up in the category list that is available when people try to add or modify a link.

If you wanted to eliminate it from displaying in the category list (which you indicate you do not want to, but others doing something similar might want to), go to sub build_category_information in nph-build.cgi and after the following code:

Code:
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);

add the following:

Code:
next LINE if (@values[$db_main_category] =~ "category_to_exclude");

Be careful when creating the name of the category you want to exclude. If it is a substring of another category, you will end up excluding all the categories that contain that name; so it should be a unique name.

I hope this helps.

[This message has been edited by Bobsie (edited May 26, 1999).]
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
That wasn't it but I think we are on the right track.

I am wanting to create a category that is built like normal & people can add & modify links like normal, but I want to exclude this category from the main category listing that is created from the "home.html" template. I intend to create a permanent link to this category.

Thanks for your assistance Bobsie, I appreciate it!
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
Okay, then here is what to do.

Create a duplicate of sub site_html_print_cat in site_html_templates.pl and call it "sub site_html_print_home_cat".

Change the following in sub site_html_print_home_cat:

Code:
foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];

to read:

Code:
foreach $subcat (sort @subcat) {
next if (@{$category{$subcat}}[1] =~ "category_to_exclude");
($description) = @{$category{$subcat}}[2];

Then in sub build_home_page, nph-build.cgi, change:

Code:
$category = &site_html_print_cat (@rootcat) if ($#rootcat >= 0);

to read:

Code:
$category = &site_html_print_home_cat (@rootcat) if ($#rootcat >= 0);

I hope this helps.
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
OK, That got the category to stay hidden but caused 2 additional problems, however I was able to resolve the first issue. Once I made the above changes and built the pages I noticed my columns on the home page were nolonger aligned correctly. I found the following line in site_html_templates.pl:

my ($half) = int (($#subcat+2) /2);

In my case since I had 15 Categories (14 to display & 1 hidden) I took the total categories divided by 2 minus the 1 hidden cat.

my ($half) = int ((($#subcat+2) /2)-1);


My second problem that I wasn't able to correct is that when I go to my hidden category's built page and attempt to add or modify a link I get the following error:

category: error building select field: no select fields specified in config for field 'Category'!

I appreciate any help to resolve this issue!
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
Now that's odd. We haven't elminated the category, we just hid it in home.html. It should still be in the category list that is used for add's and modify's. Makes sure your sub site_html_add (site_html.pl or site_html_templates.pl) contains the following:

Code:
$category ?
($category = qq~$category <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
No that part is correct. Let me tell you exactly what I have done thus far:

Changed all files to ".pl" (did search & replace)
Installed Yahoo template
Added special character "&"

Other than what we are doing now and modifying html that is all I have changed. Thanks for the assistance!
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
OK, I know what the problem is. How to fix it overall is a different story (as I really don't know this stuff I just fumble my way through it).

In site_html_templates.pl under the sub site_html_add & sub site_html_modify sections there is a certain combination of either category or Category. When you said to make sure the following was correct:

$category ?
($category = qq~$category <input type=hidden name="Category" value="$category">~):
($category = &build_select_field ("Category", "$in{'Category'}"));


I'm not sure what I originally had but this is what works (without the capital "C"):

$category ?
($category = qq~$category <input type=hidden name="category" value="$category">~):
($category = &build_select_field ("category", "$in{'Category'}"));


One last thing Bobsie, on each categories individual page if I click on "add a link" the add page will show Category: "Category_Name" rather then the select box. When I go to the page for my hidden category it shows a select box rather than the category name. Is there any way to make this show up with the actual category name so my users don't have to select the category from the drop-down list?

Thanks for all the help!
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
Again, that should be done if the Add A Link option is chosen while on the "hidden" category page as that is how Links is designed to work. The only time a select list is supposed to come up is when you go to Add A Link from other than a category page.

Since nph-build.cgi builds your category pages all the same based on the templates and the code in site_html_templates.pl, I don't understand why it wouldn't work correctly on that one category page. Again, the only thing you changed was the display of that category on the home page. Nothing else was changed anywhere else.

What's the URL to your site? I would like to see this for myself.

[This message has been edited by Bobsie (edited June 03, 1999).]
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
If anyone is having any problems with the code posted on any HTML pages either here at this site or anywhere else, here is a URL to download an updated Template.pm that Alex himself configured for me - which appears to work. I can't say I've tested any code posted anywhere else. I can only tell you that this works for me! - Good Luck and let me know how you get on if you use it.

gary.cheers@virgin.net
DOWNLOAD:
http://www.man-united.net/Template.pm

Quote Reply
Re: creating hidden category or 2nd database...? In reply to
Bobsie, I went through all the files & reverted all forms of category or Category back to the links default. All the add & modify pages work however I am still receiving the problem with the "add a site" giving me a select box on the hidden directory & it is doing the same on all modify pages.

The site is located at http://www.springnet1.net

The hidden category is located on the left side "UserWeb Directory".
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
I see the problem but have no idea why it is doing what it is doing. Can you do me a favor? Zip up your links admin directory, to include sub directories (except the admin/backup, admin/data/hits and admin/data/ratings directories) and send it to me. I will setup a test page for it and see if I can figure it out.

Just file attach it to an email message at the address below or put it online and tell me the URL for it and I will download it and test it out as soon as I can.

Thanks.

Email to: bobsie@orphanage.com

[This message has been edited by Bobsie (edited June 07, 1999).]
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
Okay, I have figured out the problem with the hidden category not handling the category correctly. It had me scratching my head for a while until I noticed that the URL of the hidden category that was displaying in the location box of my browser did not match the punctuation of the category.

In your templates.cfg file, change:

Quote:
$userserv_url3 = 'userweb_directory/';

to read:

Quote:
$userserv_url3 = 'UserWeb_Directory/';

The other problem you mentioned, not displaying the category in modify.cgi is simple since it isn't a problem to begin with. The category doesn't display in the modify form because there is no way to know the category until the user puts it in. That's the purpose of the form and the category might be one of the items the link owner wants to modify.

I hope this helps.

[This message has been edited by Bobsie (edited June 08, 1999).]
Quote Reply
Re: creating hidden category or 2nd database...? In reply to
Thanks for all the assistance Bobsie!