Gossamer Forum
Quote Reply
global for category list
I’m looking for a global that will create inside a category links to its peer-categories, that are in the same level.
For example if I have under the category “Alphabetical List” all the ABC in sub-categories, than I want that inside the sub-category “A” there will be link to its peer sub-categories ”B” to “Z”.

I also want the same idea for the details page: for example, that in the details page of “Alice’s Shoe Store”, I’ll have links for categories “B” to “Z”.

Does somebody have a global that can do this? Crazy
Quote Reply
Re: [nir] global for category list In reply to
Hi, this is my last try for this week...I still didn't solve this problem.
What do I have to do so that in a certain category I can also show links to other same-level categories, and not only the content of the category.
For example, in category "C", in addition to links that start with C there will be links to categories A, B, D, and so on.
Quote Reply
Re: [nir] global for category list In reply to
Related categories?
Quote Reply
Re: [gotze] global for category list In reply to
No, it's not related categories, because every time I'll add a category I'll have to link it to the old ones.
It's like if I have a category "countries" and I'm in "G" (Germany, Greece) and I want to jump to Italy, I want to have a link to "I" from within the "G" , instead of going back to "Alphabetical List" and then choose "I".
Quote Reply
Re: [nir] global for category list In reply to
Assuming that FatherID is an available tag on the page - something like this (untested):

sub {
my $args=shift;
my $db = $DB->table ('Category');
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: [afinlr] global for category list In reply to
How I call to this global,
I create global name cat_list but I don’t success to make it work
Quote Reply
Re: [nir] global for category list In reply to
Hi,

It is returning a loop so you'll need something like
<%cat_list%><%loop more_cats_loop%><%Name%> links etc...<%endloop%>
Quote Reply
Re: [afinlr] global for category list In reply to
I get error massage:
Unable to compile 'cat_list': Missing right curly or square bracket at (eval 27) line 11, at end of line syntax error at (eval 27) line 11, at EOF
Quote Reply
Re: [nir] global for category list In reply to
Sorry - try this:

sub {
my $args=shift;
my $db = $DB->table ('Category');
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: [afinlr] global for category list In reply to
After I make the latest change I don’t get anything it like there is not category to show.
I test it like this
11
<%cat_list%><%loop more_cats_loop%><%Name%><%endloop%>
22

But I get in the site just the number 11 22.
Quote Reply
Re: [nir] global for category list In reply to
Sorry - knew it would be buggy if I didn't test it!

fetchrow_array should be fetchrow_hashref
Quote Reply
Re: [afinlr] global for category list In reply to
ThanksSmile
It work on the category pages, is it possible that it will work on the details page too.
Can you change the code so the order of the category will be Alphabetical List from 0-9 and from a-z.
Again Thanks for your help
Quote Reply
Re: [nir] global for category list In reply to
Unfortunately it is more complicated on the detail pages as the category isn't unique so getting the FatherID is difficult.

If you want to sort by Name try this:

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: [afinlr] global for category list In reply to
Can you tell me how I can get the url of the category.