Gossamer Forum
Quote Reply
Same level category list
Hi,
I think I posted this in the wrong place before. I am looking for a way to list the same level categories on each category page, so at the bottom of the category page I would list the other categories on the same level with a title like "Try these other categories", I am not looking to list "related categories", but all the categories that are on the same level as the present category.
Thanks,
George
Quote Reply
Re: [macbethgr] Same level category list In reply to
<%getlevelcats($FatherID)%>

sub {
my $fatherid = shift;
my $db = $DB->table('Category');
my $sth = $relation->select({FatherID=>$fatherid});
my $output;
while (my $cat = $sth->fetchrow_hashref){
my $url=$DB->table('Category')->as_url($cat->{Full_Name);
$output.=qq~<li><a href="$CFG->{build_root_url}/$url">$cat->{Name}</a>~;
}
return $output;
}

Untested.
Quote Reply
Re: [afinlr] Same level category list In reply to
Thanks for replying. I got " Unable to compile 'getlevelcats': " when I tried it.

George
Quote Reply
Re: [macbethgr] Same level category list In reply to
Oops - try this

sub {
my $fatherid = shift;
my $db = $DB->table('Category');
my $sth = $db->select({FatherID=>$fatherid});
my $output;
while (my $cat = $sth->fetchrow_hashref){
my $url=$DB->table('Category')->as_url($cat->{Full_Name);
$output.=qq~<li><a href="$CFG->{build_root_url}/$url">$cat->{Name}</a>~;
}
return $output;
}

Last edited by:

afinlr: Sep 29, 2004, 12:41 PM
Quote Reply
Re: [macbethgr] Same level category list In reply to
Add a new } sign at the end of code.
Code:
return $output;
}
}

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Same level category list In reply to
Still the same...
George
Quote Reply
Re: [macbethgr] Same level category list In reply to
Code:
sub {
my $fatherid = shift;
my $db = $DB->table('Category');
my $sth = $db->select({FatherID=>$fatherid});
my $output;
while (my $cat = $sth->fetchrow_hashref){
my $url=$DB->table('Category')->as_url($cat->{Full_Name});
$output.=qq~<li><a href="$CFG->{build_root_url}/$url">$cat->{Name}</a>~;
}
return $output;
}
That's now syntactically correct.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Same level category list In reply to
That did it.... thanks
Quote Reply
Re: [macbethgr] Same level category list In reply to
Sorry - normally try to test my globals but was very busy today. When I first wrote the reply I started off by explaining what the global needed to do and then decided that was a bit mean when I knew that it would only take me a couple of minutes to write - but there goes the accuracy!

Glad you got it working eventually. And thanks webmaster33 for sorting out my error.