Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Next/Prev on detail with 2 or more cats

Quote Reply
Next/Prev on detail with 2 or more cats
There is a logical problem on the prev/next links while using more than one cat for a link.

Example:
Link1 in Cat1
Link2 in Cat1
Link3 in Cat2
Link4 in Cat2

On detail you could go from Link1 to link2 and vice versa; from Link3 to Link4 and vv.
Problem while:

Link1 in Cat1
Link2 in Cat1
Link3 in Cat1
Link3 in Cat2

Link1 to Link2
Link3 to nowhwere.

For my special needs i want the order for next/prev only for one single cat, beacuse every link is in this cat. Has someone a clue where to hack what for this?

In Example cat1 would be the master-cat.
Quote Reply
Re: [Robert] Next/Prev on detail with 2 or more cats In reply to
Code:
sub get_categories {
# -------------------------------------------------------------------
# Takes a link id and returns a hash of category id => category name.
#
my $self = shift;
my $id = shift;
my $db = $DB->table('Category', 'CatLinks');
my $sth = $db->select( { 'CatLinks.LinkID' => $id }, [ 'Category.ID', 'Category.Full_Name' ] );
my %res = ();
while (my ($id, $name) = $sth->fetchrow_array) {
$res{$id} = $name;
}
return \%res;
}

Here it seems is the point for my problem; in build.pm it is:

my ($cat_id, $cat_name) = each %{$link_db->get_categories($link->{ID})};

for getting the cat_id; while get_categories always push out the last cat!
Quote Reply
Re: [Robert] Next/Prev on detail with 2 or more cats In reply to
Solved for my needs with $db->select_options("ORDER BY Category.ID ASC LIMIT 1"); in get_categories ;-)
Hope so ;-)