Gossamer Forum
Quote Reply
category same level
How can I display category list of the same level by sending category ID,

I use this global but it work from categry.html and it work without send the ID of the category
sub {
my $args=shift;
my $db = $DB->table ('Category');
$db->select_options('ORDER BY Name');
my $sth = $db->select ( {FatherID=>$args->{FatherID}});
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
unless ($cat->{ID} == $args->{ID}) {
if ($cat->{ID} == '1') { next; } #
$cat->{URL} = $CFG->{build_root_url} . '/' . $DB->table('Category')->as_url( $cat->{Full_Name} ) . '/' . $CFG->{build_index};

push @cats, $cat;
} }
return {more_cats_loop=>\@cats}
}
Quote Reply
Re: [nir] category same level In reply to
Hi,

Not really sure what your asking for? =)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] category same level In reply to
Hi AndySmile,
I want to send to a globule canegoryID and get list of all categories in the same level.
Quote Reply
Re: [nir] category same level In reply to
So if you have these categories:

1- Test
2- Test/Sub cat
3- Test/Sub cat/Another sub
4- Test/Sub cat/Another sub2
5- Test/Sub cat/Another sub3
6- Test2
7- Test/Sub cat2
8- Test/Sub cat2/Another sub
9- Test/Sub cat2/Another sub2
10- Test/Sub cat2/Another sub3

...and you are in the current category "10", you would want it to load:

3- Test/Sub cat/Another sub
4- Test/Sub cat/Another sub2
5- Test/Sub cat/Another sub3
8- Test/Sub cat2/Another sub
9- Test/Sub cat2/Another sub2

..is that right?

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] category same level In reply to
If I in category 10, I would like to get the category,
8- Test/Sub cat2/Another sub
9- Test/Sub cat2/Another sub2

And not the next one as there path is with "Sub cat" and not "Sub cat2"
3- Test/Sub cat/Another sub
4- Test/Sub cat/Another sub2
5- Test/Sub cat/Another sub3
Quote Reply
Re: [nir] category same level In reply to
Give this a go (untested). This is for category.html (won't work in any other template)

get_categories_below
Code:
sub {
my $current_category = $_[0];
my $father_id = $_[1];

my @loop;
my $tbl = $DB->table('Category');
$tbl->select_options("ORDER BY Name DESC");

my $sth = $tbl->select(GT::SQL::Condition->new('FatherID','=',$father_id,'ID','<>',$current_category)) || die $GT::SQL::error;

while (my $hit = $sth->fetchrow_hashref) {
$hit->{URL} = $CFG->{build_root_url} . "/" . $tbl->as_url($hit->{Full_Name}) . "/" . $CFG->{build_index};
push @loop, $hit;
}
return { other_cats => \@loop }
}

Code:
<%get_categories_below($ID,$FatherID)%>
<%if other_cats.length%>
<%loop other_cats%>
<%include subcategory.html%>
<%endloop%>
<%endif%>

Cheersw

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] category same level In reply to
WinkThanks,