Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Hide Categories - when submitting link

Quote Reply
Hide Categories - when submitting link
Hi All

There are only a few categories that we want visitors to submit links for. These categories should obviously be listed on the add.html page when a visitor wants to submit a link.

However, there are other categories that we do not want visitors to submit links for. These other categories are for internal purposes.

Other than hardcoding the add.html page with the allowed cats, is there a way to designate which categories can be displayed (or hidden) when a visitor clicks add.cgi?

Thanks Smile

------------------------------------------

Last edited by:

DogTags: May 15, 2004, 6:45 AM
Quote Reply
Re: [DogTags] Hide Categories - when submitting link In reply to
You could add another field, say "canAdd" to the category table, and then in /admin/Links/User/Add.pm, you could modify the bottom subroutine, which generated the dropdown category. Make it so that it does something like;

$table->select( { canAdd => 'Yes' });

... or something along those lines. If you want, paste the routine here, and I'll show you what changes to make (dont have time to start logging in and trying to find it Frown).

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] Hide Categories - when submitting link In reply to
Thanks, And. I'll dig in over the next few days and come up with that section Smile

------------------------------------------
Quote Reply
Re: [Andy] Hide Categories - when submitting link In reply to
Hey And

Here is the _sub_category routine. I placed your line of code where I thought it should go (bold):

Code:
sub _category_list {
# -------------------------------------------------------------------
# Return a list of all the categories.
#
my $category;
$table->select( { canAdd => 'Yes' }); # Is this the right place for this?
if ($CFG->{db_gen_category_list}) {
my $db = $DB->table('Links');
my $html = $DB->html($db, $IN);
my @ids = $IN->param('CatLinks.CategoryID') || $IN->param('ID');
$category = $html->get_all_categories(\@ids, 'CatLinks.CategoryID', 1);
}
else {
my $db = $DB->table('Category');
my $id = $IN->param('CatLinks.CategoryID') || $IN->param('ID');
my $sth = $db->select( { ID => $id }, ['Full_Name'] );
my ($name) = $sth->fetchrow_array();
if ($name) {
$category = "$name <input type=hidden name='CatLinks.CategoryID' value='$id'>";
}
else {
return;
}
}
return $category;
}

Any boo-boos?

Thanks Smile

------------------------------------------
Quote Reply
Re: [DogTags] Hide Categories - when submitting link In reply to
Looking at it, you would probably need to edit /admin/Links/Link.pm, on about line 571~. There should be something like;

Code:
my $sth = $db->select ( ['ID', 'Full_Name'] );

Try changing it to;

Code:
my $sth = $db->select ( ['ID', 'Full_Name'], { canAdd => 'Yes' } );

Don't forget that you also need to edit the "Category" table, through Database > Category > Properties, and add the 'canAdd' ENUM/select field in :) I'd suggest setting the default to 'Yes' :)

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] Hide Categories - when submitting link In reply to
Hi And

1. I did not find /admin/Links/Link.pm

(I am using version LinksSQL 2.2.0 - if that matters)

I did find /admin/Link.pm

I also found /admin/Links/HTML

2. Does the sub _category_list look correct?

Code:
sub _category_list {
# -------------------------------------------------------------------
# Return a list of all the categories.
#
my $category;
$table->select( { canAdd => 'Yes' }); # Is this the right place for this?
if ($CFG->{db_gen_category_list}) {
my $db = $DB->table('Links');
my $html = $DB->html($db, $IN);
my @ids = $IN->param('CatLinks.CategoryID') || $IN->param('ID');
$category = $html->get_all_categories(\@ids, 'CatLinks.CategoryID', 1);
}
else {
my $db = $DB->table('Category');
my $id = $IN->param('CatLinks.CategoryID') || $IN->param('ID');
my $sth = $db->select( { ID => $id }, ['Full_Name'] );
my ($name) = $sth->fetchrow_array();
if ($name) {
$category = "$name <input type=hidden name='CatLinks.CategoryID' value='$id'>";
}
else {
return;
}
}
return $category;
}

Thanks, And Smile

------------------------------------------

Last edited by:

DogTags: May 19, 2004, 7:35 AM
Quote Reply
Re: [DogTags] Hide Categories - when submitting link In reply to
I think it may have been on 2.1.2, but I could be wrong. It should exist.

If not, then /admin/Link.pm is probably the one. Look for;

Code:
sub get_all_categories {

..and then look for the code I provided, and put it in :) That should work.

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] Hide Categories - when submitting link In reply to
It seems that there has been a change:

Links 2.2.0

/admin/Links/HTML/Category.pm
/admin/Links/HTML/Links.pm
/admin/Links/HTML/Users.pm

I found sub get_all_categories in there at about line 252

I'll plug in your stuff and see how it goes.

Thanks, And Smile

------------------------------------------
Quote Reply
Re: [DogTags] Hide Categories - when submitting link In reply to
Looks good so far Smile

My test_cat_no_add was excluded from the add.html select list Cool

This would be a nice default feature of the script (hint, hint Goss Gang Smile )

------------------------------------------

Last edited by:

DogTags: May 19, 2004, 8:52 AM
Quote Reply
Re: [DogTags] Hide Categories - when submitting link In reply to
i followed the instructions to a tee, but i am getting internal error massage

please help