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

Prevent additions to main categories

Quote Reply
Prevent additions to main categories
Hi, I was wondering if there was a way to prevent people from adding links to my main categories, basically those with FatherID of 0,

Either through not displaying the main categories in the select form, or something that sends back an error if the fatherid of the category is 0

Anyone?
Quote Reply
Re: [kzap] Prevent additions to main categories In reply to
This is what I have been using.

http://www.gossamer-threads.com/...string=issub;#102824
Quote Reply
Re: [kzap] Prevent additions to main categories In reply to
hmm nahh, im looking for something simpler, maybe a more simpler category loop. Thanks to a previous global from Andy, I've come up with this, I just need to know how to make it get all those which FatherID is greather than 0 ? Anyone?

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

$table->select_options ('ORDER BY Name ASC');
my $sth = $table->select( { FatherID => '0' } );

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

return $return_cats;
}

Last edited by:

kzap: Sep 14, 2003, 10:34 PM
Quote Reply
Re: [kzap] Prevent additions to main categories In reply to
Hi. Try this. It should list cateogires where the father ID is greater than 0 (i.e not root categories)....

Code:
sub {

my $table = $DB->table('Category');
my $return_cats;

$table->select_options ('ORDER BY Name ASC');
my $cond = GT::SQL::Condition->new('FatherID','>','0');
my $sth = $table->select( $cond );

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

return $return_cats;
}

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] Prevent additions to main categories In reply to
Thanks, I finally came up with this for it to be able to accept a catid if there is one and to sort it properly. Just want to check though, is <%category%> sorted by Full_Name , or DirName, or something else?

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('FatherID','>','0');
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;
}
Quote Reply
Re: [kzap] Prevent additions to main categories In reply to
>>> Just want to check though, is <%category%> sorted by Full_Name <<<

As far as I know, its done by Full_Name ASC.

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] Prevent additions to main categories In reply to
ok thanks =)