Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Multiple categories, Add.pm, Modify.pm : major problems

Quote Reply
Multiple categories, Add.pm, Modify.pm : major problems
Hello ...

We are having extreme difficulty with our public add and modify forms.
GT staff: can you help out here please? Everything is explained below ...

----------------------------------------------------------------
Background:

All our links are in multiple categories.
The editors -- not the users -- select the categories, based on a thorough review of the link.
The categories are not an afterthought for the link -- they are core information, just like the description.
Failure to specify a category is not an error for us. In the Add form it is irrelevant, but in the Modify form it is a requirement that users cannot mess with the category set, which represent significant editorial work.
db_gen_category_list must be set to Yes -- because it determines the display of categories in the Admin interface

----------------------------------------------------------------
Add.pm

The Problem:
By default, Add.pm requires a category input, something we do not need or want.

The Solution:
Either disable the category input, or pass the current category as a hidden input (as happens when db_gen_category_list is set to No).
Our temporary workaround is an edit at line 191 of Add.pm: replace if ($CFG->{db_gen_category_list}) with if (0). This has the same effect as db_gen_category_list = No. The editors can then treat the category as a suggestion.


----------------------------------------------------------------
Modify.pm

The Problem:
This is a major bug -- the modify form can have only one input field for CatLinks.CategoryID, so when the user submits it, essential information about the link (all the other categories) is destroyed. Effectively, Modify.pm cannot be used as the damage caused is greater than the benefit.

The Solution:
Disable category input completely, so that when Admin or Editors validate the modified link the original CatLinks.CategoryID set remains intact.
We have no workaround.


However, we think this might not be too difficult to fix. All we need to do is circumvent the code in Modify.pm which rejects submissions which do not specify a category. But we can't figure out where it happens.
Quote Reply
Re: [YoYoYoYo] Multiple categories, Add.pm, Modify.pm : major problems In reply to
Every link has to have a category, or it's an orphan. This is not a bug.

You can pass a dummy category, such as '0' in to the system, or better yet, create a "pending" category and use that. There was some discussion a few weeks ago how to hide a category, and you could hid it.

As for the modify/category-select, this is probably a bug in the routine, that should send out a multiple-select box, rather than a select-box.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Multiple categories, Add.pm, Modify.pm : major problems In reply to
In Reply To:
Every link has to have a category, or it's an orphan. This is not a bug.
That's true -- our Add.pm workaround takes care of it.

In Reply To:
As for the modify/category-select, this is probably a bug in the routine, that should send out a multiple-select box, rather than a select-box.
A bug, or a programming oversight ...

But it is also a usability bug -- it allows the user to inadvertently override Admin decisions, and Admin can't stop it. We do need a multiple-select box, but we also need an option to disable category selection by users.

These links are not orphans, they are in multiple categories. The only way we can stop users from trashing hours of work is to stop them modifying anything. Suppose the link is in 5 categories -- after the user has updated the description, or whatever, it is in only one category. All we want to do is allow users to modify their links without being compelled to reduce a multiple category link to a single category link.

Here is the flaw in the logic -- if we remove the input field for the CatLinks.CategoryID, the script complains that the link has no category -- but it doesn't check to see if it is actually true -- it only looks at the form input, not what is already in the database.

Alternatively, if the link is displayed in a category it cannot be an orphan, so there is no need to check. Absence of a value for CatLinks.CategoryID can be justified as an error in Add.pm, but never in Modify.pm -- the link should simply retain the values it already has.

I have tried to find the code where the superfluous check occurs, so I can comment it out, but it is too much for someone who is not an experienced Perl programmer.
Quote Reply
Re: [YoYoYoYo] Multiple categories, Add.pm, Modify.pm : major problems In reply to
That's the problem I'm having!!!! I definitely am keeping an eye on this thread...Angelic

My current plan for modify is to make the categories a hidden field so Users can't change it that way (instead there will be a list of what categories the link is currently in) and add two more fields; Add to and Deleted from. The User will then list what categories s/he want's the link to appear in or be deleted from there. The Editors (or, in my case, Moderators) will then copy the link to the appropriate categories.

(Hiding the field should work that way, right? I hope?)

If there's a better way, I definetely want to hear it!!!

What's your site, YoYoYoYo?

Last edited by:

rayhne: Jul 23, 2002, 6:27 AM
Quote Reply
Re: [rayhne] Multiple categories, Add.pm, Modify.pm : major problems In reply to
If I hide the category field for the forms, does it also hide the categories in the Admin area? Is that the problem I'm reading here?
Quote Reply
Re: [rayhne] Multiple categories, Add.pm, Modify.pm : major problems In reply to
In Reply To:
My current plan for modify is to make the categories a hidden field so Users can't change it that way
But how? A hidden input for each category? That is an ambitious modification!

In Reply To:
What's your site, YoYoYoYo?
It's password-protected until ready for launch, no idea when, but can't happen before this is fixed.

In Reply To:
If I hide the category field for the forms, does it also hide the categories in the Admin area? Is that the problem I'm reading here?
Close, depending on other modifications you might have made. If db_gen_category_list == No, you get a hidden form input for one category, but then category selection in the Admin area is totally trashed. If you have multiple categories, it's not even an option, db_gen_category_list must be Yes.
Quote Reply
Re: [YoYoYoYo] Multiple categories, Add.pm, Modify.pm : major problems In reply to
Actually, what I mean is what kind of site do/will you have?

I don't use multiple categories, I use the copy feature.

By hidden field, I just mean setting that build option to no. I took a quick look at the admin area with it set to no and it looks like it might work for me. :) Off to rebuild my add/modify templates!!!!

Last edited by:

rayhne: Jul 23, 2002, 9:30 AM
Quote Reply
Re: [rayhne] Multiple categories, Add.pm, Modify.pm : major problems In reply to
In Reply To:
Actually, what I mean is what kind of site do/will you have?
It's a portal for natural resource managers, researchers, rangers and game wardens in Africa. They usually don't have much time, inclination or opportunity to use the Internet, and have always got other things to do. We are using LSQL to annotate, review and categorize the major resources (for data, information, experiences, contacts, issues) so they don't have to dig around themselves. The editors have to examine each web site in depth to report on what is there, from the field professional's viewpoint, then put it in appropriate categories. Losing the categories is a real hassle -- it's happened to me several times already through my own mistakes.

In Reply To:
I don't use multiple categories, I use the copy feature.
Same thing. To get multiple categories, we copy the links.
Quote Reply
Re: [YoYoYoYo] Multiple categories, Add.pm, Modify.pm : major problems In reply to
Sounds like a great site...I'll have to check it out. :)

What I meant is, I don't select the other categories by CTRL or Shift-CTRL down the drop-down menu but copy them to other categories so I don't need the drop-down menu of categories in the admin area. (if that makes any sense.)
Quote Reply
Re: [YoYoYoYo] Multiple categories, Add.pm, Modify.pm : major problems In reply to
This multiple category selection problem for user modifications was solved in this forum on May 14th.

Please see the thread: -

http://www.gossamer-threads.com/...?post=196090;#196090

Cheers,

Warwick Evans

http://www.humorlinks.com

Quote Reply
Re: [humorlinks] Multiple categories, Add.pm, Modify.pm : major problems In reply to
In Reply To:
This multiple category selection problem for user modifications was solved in this forum ...
Yes it was. But this is a totally different problem !!!.
It is quite possible to have users submit several categories simultaneously in a modify form. But having them submit many categories is not better than having them submit only one!

What we need to do is have users submit zero categories in a modify form. It is an absolute requirement that the modify form should return no categories at all -- not multiple categories, no categories. The link that is being modified already has categories which must not be changed by the user in any circumstances.

The solution is simply to allow users to modify links without affecting the categories, just like the other columns which they may not alter.

What prevents them? Nothing much -- just a bit of code somewhere that rejects a modify form if there is no category input field -- but we can't find that bit of code.
Quote Reply
Re: [YoYoYoYo] Multiple categories, Add.pm, Modify.pm : major problems In reply to
Regarding the modify problem:

if you set db_gen_category_list to 0 and use the Modify.pm I sent you, it should work (i.e. users will see a list of categories, but they cannot change them).

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Multiple categories, Add.pm, Modify.pm : major problems In reply to
In Reply To:
if you set db_gen_category_list to 0 and use the Modify.pm I sent you, it should work (i.e. users will see a list of categories, but they cannot change them).
Hello, thanks for all the help and consideration. We are trying out your Modify.pm (and it is definitely better than the default), but we have to keep db_gen_category_list = Yes. If we turn it off for the users, we turn it off for Admin as well -- and that would be a greater problem than the one solved.
Quote Reply
Re: [YoYoYoYo] Multiple categories, Add.pm, Modify.pm : major problems In reply to
Ok,

Here's an idea.

In Modify.pm, in the sub modify, you'll see:

# Make sure the category id's are valid.
$IN->param('CatLinks.CategoryID')
or return { error => Links::language('MODIFY_NOCATEGORY'), Category => $category, LinkID => $lid };


Change that line to:

my $old_cats = $db->get_categories ($lid);
$IN->param('CatLinks.CategoryID', $lid);

Basically, overwrite the input categories with the old ones. It's a lot of wasted effort, but it's a simple change, that you could make between versions, with only limited code changes.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [YoYoYoYo] Multiple categories, Add.pm, Modify.pm : major problems In reply to
You can turn db_gen_category_list off, and then hack Links/Link.pm, around line 478

Replace:

# Display category as a select box.
if ($CFG->{db_gen_category_list}) {


with

# Display category as a select box.
if (1) {

and the admin will always see a select box.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Eureka! In reply to
We would like to acknowledge our debt to everyone who has helped out, publicly and privately, with this seemingly intractable problem. In the end, we have gone with Yogi's workaround (immediately above this post) -- it fitted in best with all the other mods we had already made.

So now we can display the modify form without fear, uncertainty or doubt. It shows users which categories the link is in, but does not allow users to change those categories -- intentionally or unintentionally. The original categories are selected in the Admin validation form.

It is all we needed. Thanks very much!

Now I'm takng a break for two weeks ...
Quote Reply
Re: [humorlinks] Multiple categories, Add.pm, Modify.pm : major problems In reply to
hello humorlinks,

I have use your modification & it works perfect.
I had one isue, the Full_name of the categories would not displayed.

I have done the following rewrite:

1, changed while in a localvariable called $name & use this fariable in the loop, now i can use something like $name->{Full_Name}
to use this I should use step 2.
2. changed fetchrow_array in fetchrow_hashref


see code below

sub {
my ($rec) = @_;
my $id = $rec->{ID};
my $db = $DB->table('CatLinks');
my @sids = $db->select ( ['CategoryID'], { 'LinkID' => $id } )->fetchall_list;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name ASC');
my $sth = $cat_db->select;
my $output;
$output .= "<SELECT CLASS='form' MULTIPLE SIZE='7' NAME='CatLinks.CategoryID'>";
$output .= "<OPTION VALUE=''>---</OPTION>";
while (my $name = $sth->fetchrow_hashref) {
$output .= "<OPTION VALUE='$name->{ID}'";
foreach my $sid (@sids) {
if ($sid eq $name->{ID}) {
$output .= " SELECTED";
}
}
$output .= ">$name->{Full_name}</OPTION>";
}
$output .= "</SELECT>";
return $output;
}


this changes works perfect in my Links-SQL distribution (2.1.1)
Quote Reply
Re: [ridesworld] Multiple categories, Add.pm, Modify.pm : major problems In reply to
Hello

I found a trouble in the multiple select written by humorlinks.

after an error message, all your selections are gone.
what is the best solution for it?
Quote Reply
Re: [yogi] Multiple categories, Add.pm, Modify.pm : major problems In reply to
In Reply To:
You can turn db_gen_category_list off, and then hack Links/Link.pm, around line 478

Replace:

# Display category as a select box.
if ($CFG->{db_gen_category_list}) {


with

# Display category as a select box.
if (1) {

and the admin will always see a select box.


I was wondering if there may be something missing in this thread.

I tried the above code and what happens is that only the 1st category is submitted and the rest are deleted.

I tried the PugDog suggestion and it works but in the admin screen it shows the link with no categories.

I tried combining the 2 suggestions and ended up with the link in no categories and it does not appear asa an orphan.

Any clarification would be appreciated.

Thanks,
Richard White
http://www.AffiliateFirst.com