Gossamer Forum
Home : Products : Gossamer Links : Discussions :

and there were two of them...

Quote Reply
and there were two of them...
Hello Blush

I like that admin can add one link to several categories.
BUT... Is there a way how can I give this possibility also to users? I've been searching everywhere, but I just didn't find it Pirate. I hope that just changing the properities of the select box to "multiselect" would be fine and enough. Where can I do it?

Thank you in ahead for any hints on this subject Smile

Robo
Quote Reply
Re: [Robo] and there were two of them... In reply to
Hi

No just changing the catgeory to multiselect WILL NOT DO..

You see the Links table structure accepts one category Id as a category then the rest will be alternate categories...

check out those search results for Altcategory your answer lays there:

http://www.gossamer-threads.com/...string=AltCategories+
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] and there were two of them... In reply to
oh.. i see...

thank you for quick response...
anyway - WHERE can I learn more about AltCategories mod?? The search result list, you've provided, just made me confused - those are all just comments on AltCategories mod. Where is it's original page?

can you clear this up please?

thank you again.. robo
Quote Reply
Re: [Robo] and there were two of them... In reply to
The altcategories mod is for Links2...Links SQL already provides this functionality.
Quote Reply
Re: [Paul] and there were two of them... In reply to
Thank you for clearing this up!

BUT!! How can I present the users with multi-select category box ?!?!?!

I belive it's something simple, but I just wasn't able to find out Crazy

Thank you for any suggestions :-)

Robo
Quote Reply
Re: [Robo] and there were two of them... In reply to
Indeed I would love to present users with the category multi-select box, which would be exactly the same as that one in the admin section. I mean I don't need nothing special - just the same box for the users as well as for the admin.
Quote Reply
Re: [Paul] and there were two of them... In reply to
Hello Smile

Sorry for putting this up again (I feel I am getting boring):

IS there some way how to present users with multi-select category box? Exactly the same as that one in the admin section would be just fine.

Thank you for clearing this up Wink

Robo
Quote Reply
Re: [Robo] and there were two of them... In reply to
As far as I can see there is no simple way of doing it unless it is in the admin.

A possibility is to allow visitors to add other categories once the record has been validated through the modify page. I doubt that this solution is satisfactory.
Quote Reply
Re: [tpl] and there were two of them... In reply to
Thank you for your post tpl !

HOW can I present users with multi-select category box on the modify page?? I thought it was the same...

Well, can somebody from GT finally post something about this? All good portals allow users to submit to more than one category and I am sure LSQL can also do it.. it is a good piece of soft!
Quote Reply
Re: [Robo] and there were two of them... In reply to
Hi,

You could get a global to fetch the list of categories, and then you insert the code to update the database in a plugin when the modify hook is called (via a plugin).

Does that make sense?
Quote Reply
Re: [tpl] and there were two of them... In reply to
Hey Robo,

Try this. Upload the attached file into your admin directory.

Then try to use this global:
Code:
sub {
my $db = $DB->table ('Category');
my $sth = $db->select ( ['ID', 'Full_Name'] );
my %res = ();
while (my ($id, $name) = $sth->fetchrow_array) {
$res{$id} = $name;
}

my $opts = {
name => 'CatLinks.CategoryID',
-options => \%res,
-multiple => 1,

size => 5,
};
my $tags = shift;
require HTML;
return HTML::select( $tags, $opts );
}
Quote Reply
Re: [Aki] and there were two of them... In reply to
Hello Aki Smile

VERY NICE first try!! I believe we're almost there. It makes cute and complete multi-select list. But there are still some bugs:

1) The categories are not listed in ABC order - that wouldn't be a problem if you have 10 categories, but it becomes nasty bug if you have more than 100 of them (I have)

2) Let's say I add a link to three categories, then - the admin validates a link. BUT - when I (as an user who added the link) go to modify that link, ONLY ONE of the selected categories is shown (I tried it 2 times and it was in both cases the first one from the ABC point of view)

3) Third point is indeed not a bug, but it is an small thing and I think it would ease the use of this multi-select a lot. Is it possible to add the list of the previously selected categories above the multi-select box? (Exactly as it is in the admin section). So that user wouldn't have to scroll all around the multi-select box to see what categories (s)he has selected long time ago.

4) This is also not a bug. Just curious: Do you know of any way how to limit (I feel the JavaScript would be the best) the number of categories selected? For example if user would select more than three categories it would pop up some error window. If you don't know, don't worry about that, I will perhaps take a look for it and then post it here.
OR could your code be modified to limit the number of categories selected and if this number is exceeded to return standard error code?

I hope if we will finisht this it would be a very nice mod for many users Sly

Thank you for helping, have a nice day, hasta luego Angelic

Robo

Last edited by:

Robo: Jul 21, 2002, 12:53 AM
Quote Reply
Re: [Robo] and there were two of them... In reply to
Hey there,

This will fix 1.

Code:
sub {
my $db = $DB->table ('Category');
$db->select_options( 'order by Full_Name' );
my $sth = $db->select ( ['ID', 'Full_Name'] );
my %res = ();
my @order;
while (my ($id, $name) = $sth->fetchrow_array) {
$res{$id} = $name;
push @order, $id;
}

my $opts = {
name => 'CatLinks.CategoryID',
-options => \%res,
-multiple => 1,

-order => \@order,

size => 5,
};
my $tags = shift;
require HTML;
return HTML::select( $tags, $opts );
}

The rest of them are a bit more wierd. 2 might be a bug in my code, though I"m not sure what's going on with that.

I thought in the links SQL system there was a way to reproduce that select box, i'll have to look a little closer. If it turns out that there is no available way, this may become a custom project. (2,3,4 are rather involved)

Aki
Quote Reply
Re: [Aki] and there were two of them... In reply to
Aki,

2) seems to be real problem. The code is designed for just one category (when a user modifies the link).

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [Aki] and there were two of them... In reply to
Thank you for going after that Aki. I will wait until you find something - I am not going to use code which will not allow to modify links too. Thank for everything you've done until this very moment

Have a nice day Tongue

Robo
Quote Reply
Re: [yogi] and there were two of them... In reply to
heeloo yogi :-)

i was looking at this older post, because the code you've submited to show list of the categories (ie. on detailed page) seemed somehow familiar to me..

it seems that this mod (user multi-select categories) has the same bug as your first submission in get_links_cat mod - in modify page it shows as selected only the LAST (in ABC order) of the link's categories. i wonder if you or somebody else could help us to fix this final bug and thus finish this mod?

Here is what we have until now:

Bug 1: fixed by last Aki's submission
Bug 2: still needs to be fixed
Feature request 1: will be provided by your get_links_cat mod
Feature request 2: i hope i will be able to do it with JavaScript (let's see final code first)

Actual code:

Code:
sub {
my $db = $DB->table ('Category');
$db->select_options( 'order by Full_Name' );
my $sth = $db->select ( ['ID', 'Full_Name'] );
my %res = ();
my @order;
while (my ($id, $name) = $sth->fetchrow_array) {
$res{$id} = $name;
push @order, $id;
}

my $opts = {
name => 'CatLinks.CategoryID',
-options => \%res,
-multiple => 1,

-order => \@order,

size => 5,
};
my $tags = shift;
require HTML;
return HTML::select( $tags, $opts );
}


P.S. necessary HTML.pm is included in one of the previous posts...
Quote Reply
Re: [Robo] and there were two of them... In reply to
Hello everybody!

Here we are again with new, more simple code:
  • To present users with multi-select category box on the add page, open admin/Links/User/Add.cgi and make following change in the code:


Code:
$category = $html->get_all_categories(\@ids, 'CatLinks.CategoryID', 5);
  • To present users with multi-select category box on the modify page, with all the link's categories selected, replace your admin/Links/User/Modify.cgi with the Modify.cgi included in this post.
    NOTE: be sure to backup your old Modify.cgi, in case of running into problems.
  • To show all the link's categories linked ABOVE the category multi-select box on the modify page, use the get_link_cats mod fully described here.


Well, there is still a piece of work missing:

We need the number of submitted categories to be limited.. ie. that user can submit to no more than 3 categories. If yes, he/she will get error message. I wonder if this can be done with some reg ex??

Any suggestions?
Quote Reply
Re: [Robo] and there were two of them... In reply to
Actually, I did not want to make this hacked version of Modify.pm public until it has been tested more thouroughly....

A word of caution: don't use it unless you know what you are doing. You will have to do the changes again if you upgrade to a newer version of Links SQL. I will not (necessarily) be providing updated versions for Modify.pm if a new version of Links SQL comes out.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] and there were two of them... In reply to
ooops Crazy
Quote Reply
Re: [Robo] and there were two of them... In reply to
Does this mod still work?
Quote Reply
Re: [dwh] and there were two of them... In reply to
More than likely not. The structure of LSQL has changed in the latest version.

It guess this could be done with a plugin (another one to the list Shocked). It should just need to hook in on the add_success hook, and then add the fields appropriatly. It would probably also need a new routine to handle the category input/output too, as that would have to change (i.e a multi-select, instead of just a single select).

I'll post something if/when I come up with it :)

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] and there were two of them... In reply to
Is there a new version of this?
Blacknight Solutions - Hosting
Search.ie
Armchair.ie
Quote Reply
Re: [blacknight] and there were two of them... In reply to
See
http://www.gossamer-threads.com/...i?post=281773#281773

for solution