Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

exclude category in dropdown mene

Quote Reply
exclude category in dropdown mene
Hi, i want to exclude certain category in the dropdown menu of add.cgi
i added a column to category called isHidden ( wen set to yes, the category in hidden)
the i modified this global:

sub {
my $catid = shift;
my $table = $DB->table('Category');
my $return_cats;

$table->select_options ('ORDER BY Full_Name ASC');
my $cond = GT::SQL::Condition->new('isHidden','=','No');
my $sth = $table->select( $cond );

while (my $hit = $sth->fetchrow_hashref) {
$return_cats .= "<option value=\"" . $hit->{ID} . "\"";
if ($catid == $hit->{ID}) { $return_cats .= "selected=\"selected\""; }
$return_cats .= ">" . $hit->{Full_Name} . "</option>";
}

return $return_cats;
}

is works, as far as excluding categorys, but the results are in a continuous line and not in a dropdown format
i want it in a dropdown format
please help
Quote Reply
Re: [ajiimd] exclude category in dropdown mene In reply to
i figured it out:

sub {
my $catid = shift;
my $table = $DB->table('Category');
my $return_cats;
$table->select_options ('ORDER BY Full_Name ASC');
my $cond = GT::SQL::Condition->new('isHidden','=','No');
my $sth = $table->select( $cond );
my $return_cats = qq|<select name="$catid">|;
while (my $hit = $sth->fetchrow_hashref) {
$return_cats .= "<option value=\"" . $hit->{ID} . "\"";
if ($catid == $hit->{ID}) { $return_cats .= "selected=\"selected\""; }
$return_cats .= ">" . $hit->{Full_Name} . "</option>";
}
$return_cats .= '</select>';
return $return_cats;
}


hope this helps someone
Quote Reply
Re: [ajiimd] exclude category in dropdown mene In reply to
i am running into a problem. <option selected> is no resolving to the category where the user selected to add their site, or in modify.html, if is not defaulted to selected category.\


please help
Quote Reply
Re: [ajiimd] exclude category in dropdown mene In reply to
can someone please help
Quote Reply
Re: [ajiimd] exclude category in dropdown mene In reply to
Try adding;

Code:
my $in_id = $IN->param('CatLinks.CategoryID') || $IN->param('ID');

...and then change;

Code:
if ($catid == $hit->{ID}) {

...to

Code:
if ($in_id == $hit->{ID}) {

<%global_name%>

...and you can pass in ?ID=1234 or CatLinks.CategoryID=1234 (the tag that is used after submitting the add form).

That should be about 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] exclude category in dropdown mene In reply to
thanks, you are a true guru

final code which works global: <%category_exclude%> placed in include_form

Here is the global:
sub {
my $catid = shift;
my $in_id = $IN->param('CatLinks.CategoryID') || $IN->param('ID');
my $table = $DB->table('Category');
my $return_cats;
$table->select_options ('ORDER BY Full_Name ASC');
my $cond = GT::SQL::Condition->new('canAdd','=','Yes');
my $sth = $table->select( $cond );
my $return_cats = qq|<select name="CatLinks.CategoryID">|;
while (my $hit = $sth->fetchrow_hashref) {
$return_cats .= "<option value=\"" . $hit->{ID} . "\"";
if ($in_id == $hit->{ID}) { $return_cats .= "selected=\"selected\""; }
$return_cats .= ">" . $hit->{Full_Name} . "</option>";
}
$return_cats .= '</select>';
return $return_cats;
}
------------------------------------
you must add a column to Category table named 'canAdd' ENUM(Yes,No) with default 'yes'
i would post it in resource, but i don't know how

thanks

Last edited by:

ajiimd: Sep 4, 2004, 6:10 AM
Quote Reply
Re: [ajiimd] exclude category in dropdown mene In reply to
Glad it worked :)

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!