Gossamer Forum
Quote Reply
Same level category
I use this global to display category in the same level of the current category, this global work form the categoey.html, what changes I need to do so I call this category with the ID of the category - <%cat_list($catid)%> and it work?

sub {
my $args=shift;
my $db = $DB->table ('Category');
$db->select_options('ORDER BY Name DESC');
my $sth = $db->select ( {FatherID=>$args->{FatherID}});
my @cats;
while (my $cat = $sth->fetchrow_array) {
unless ($cat->{ID} == $args->{ID}) {
push @cats, $cat;
} }
return {more_cats_loop=>\@cats}
}
Quote Reply
Re: [nir] Same level category In reply to
Not sure what you are trying to do?

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] Same level category In reply to
I want to get the same level category for the categoryID that I send.
<%same_level_category($catid) %>
Quote Reply
Re: [nir] Same level category In reply to
Hi,

Sorry, still not sure I follow.

$catid is only on the category.html template.

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] Same level category In reply to
I use this on the detailed.html and I have the category ID. I want to send the category id and get the same level category.
Quote Reply
Re: [nir] Same level category In reply to
This one might work

Code:
sub {

my $cid=shift;

my $csth = $DB->table('Category')->select({ID => $cid});
my $crec = $csth->fetchrow_hashref();

my $db = $DB->table ('Category');
$db->select_options('ORDER BY Name DESC');
my $sth = $db->select ( { FatherID => $crec->{FatherID} });

my @cats;

while (my $cat = $sth->fetchrow_array)
{
unless ($cat->{ID} == $cid)
{
push @cats, $cat;
}
}

return {more_cats_loop=>\@cats};

}


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Same level category In reply to
Thanks.
I get this error
Can't use string ("37") as a HASH ref while "strict refs" in use at (eval 44) line 11.
Quote Reply
Re: [nir] Same level category In reply to
Hi,

I think you need to replace:

while (my $cat = $sth->fetchrow_array)

with:

while (my $cat = $sth->fetchrow_hashref)

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] Same level category In reply to
Yea, thats it Andy... but why is it not breaking my system? ... weird.... Unsure


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Same level category In reply to
haha it should do =)

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] Same level category In reply to
It workSmileThanks EZFrag and Thanks Andy