Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [webmaster33] Plugin help needed for Prev & Next quickjump plugin!

Quote Reply
Re: [webmaster33] Plugin help needed for Prev & Next quickjump plugin! In reply to
I'm still not clear, but here is the code snip from Build.pm

Code:
# Figure out the next/prev links.
my $catlnk_db = $DB->table ('Links', 'CatLinks');
$catlnk_db->select_options ("ORDER BY $CFG->{build_sort_order_category}") if ($CFG->{build_sort_order_category});
my $sth = $catlnk_db->select ( { CategoryID => $cat_id, isValidated => 'Yes' }, [ 'Links.ID' ] );
my ($next, $prev);
while (my ($id) = $sth->fetchrow_array) {
if ($id == $link->{ID}) {
($next) = $sth->fetchrow_array;
last;
}
else {
$prev = $id;
}
}
my ($next_url, $prev_url);
if ($next) {
$next_url = "$CFG->{build_detail_url}/$next$CFG->{build_extension}";;
}
if ($prev) {
$prev_url = "$CFG->{build_detail_url}/$prev$CFG->{build_extension}";;
}


The "trick" is in the join that is done:

Code:
my $catlnk_db = $DB->table ('Links', 'CatLinks');
$catlnk_db->select_options ("ORDER BY $CFG->{build_sort_order_category}") if $CFG->{build_sort_order_category});
my $sth = $catlnk_db->select ( { CategoryID => $cat_id, isValidated => 'Yes' }, ['Links.ID' ] );


Once that is done, then the program goes on:

Code:


my ($next, $prev);
while (my ($id) = $sth->fetchrow_array) {
if ($id == $link->{ID}) {
($next) = $sth->fetchrow_array;
last;
}
else {
$prev = $id;
}
}


It does a brute-force iteration through the returned results, and picks the links.

If you were going to do this on a per-category basis, for 25 links per page, you'd want maintain the values of "prev" and "next" from link to link, so that "next" becomes "prev" without further overhead.

Again, I'm not sure why you want this on the category page.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Subject Author Views Date
Thread Plugin help needed for Prev & Next quickjump plugin! webmaster33 4748 Feb 15, 2002, 12:16 PM
Thread Re: [webmaster33] Plugin help needed for Prev & Next quickjump plugin!
pugdog 4647 Feb 15, 2002, 1:15 PM
Thread Re: [pugdog] Plugin help needed for Prev & Next quickjump plugin!
webmaster33 4607 Feb 15, 2002, 1:22 PM
Post Re: [webmaster33] Plugin help needed for Prev & Next quickjump plugin!
pugdog 4611 Feb 16, 2002, 1:30 AM
Thread Re: [pugdog] Plugin help needed for Prev & Next quickjump plugin!
webmaster33 4650 Feb 16, 2002, 1:24 AM
Thread Re: [webmaster33] Plugin help needed for Prev & Next quickjump plugin!
pugdog 4611 Feb 16, 2002, 1:48 AM
Thread Re: [pugdog] Plugin help needed for Prev & Next quickjump plugin!
webmaster33 4591 Feb 16, 2002, 1:58 AM
Thread Re: [webmaster33] Plugin help needed for Prev & Next quickjump plugin!
pugdog 4600 Feb 16, 2002, 7:32 AM
Thread Re: [pugdog] Plugin help needed for Prev & Next quickjump plugin!
pugdog 4578 Feb 16, 2002, 7:39 AM
Post Re: [pugdog] Plugin help needed for Prev & Next quickjump plugin!
webmaster33 4577 Feb 16, 2002, 10:34 AM