I'm still not clear, but here is the code snip from Build.pm
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:
$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:
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.
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.