This seems to work for me:
my $this_link_id = $_[0];
my $db = $DB->table ('Links','CatLinks');
my $cat_id = $db->select ( ['CategoryID'], { LinkID => $this_link_id } )->fetchrow;
# 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( ['Links.ID','Links.Title'] => { CategoryID => $cat_id }, VIEWABLE);
my ($next, $prev, $next_title, $prev_title);
while (my ($id,$title) = $sth->fetchrow) {
if ($id == $this_link_id) {
($next,$next_title) = $sth->fetchrow_array;
last;
}
else {
$prev = $id;
$prev_title = $title;
}
}
my ($next_url, $prev_url);
if ($next) {
$next_url = qq~<a href="$CFG->{db_cgi_url}/page.cgi?g=Detailed/$next.html&d=1">$next_title</a>~;
}
if ($prev) {
$prev_url = qq~<a href="$CFG->{db_cgi_url}/page.cgi?g=Detailed/$prev.html&d=1">$prev_title</a>~;
}
return { next_url => $next_url, prev_url => $prev_url };
}
You have to call it a little differently:
Then it will give you <%next_url%> and <%prev_url%>
I've tested it on my test install and it works perfectly:
PREV: <a href="http://gossamer.ultranerds.co.uk/cgi-bin/page.cgi?g=Detailed/268.html&d=1">NaturalDesign</a>
Cheers
Andy
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Code:
sub { my $this_link_id = $_[0];
my $db = $DB->table ('Links','CatLinks');
my $cat_id = $db->select ( ['CategoryID'], { LinkID => $this_link_id } )->fetchrow;
# 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( ['Links.ID','Links.Title'] => { CategoryID => $cat_id }, VIEWABLE);
my ($next, $prev, $next_title, $prev_title);
while (my ($id,$title) = $sth->fetchrow) {
if ($id == $this_link_id) {
($next,$next_title) = $sth->fetchrow_array;
last;
}
else {
$prev = $id;
$prev_title = $title;
}
}
my ($next_url, $prev_url);
if ($next) {
$next_url = qq~<a href="$CFG->{db_cgi_url}/page.cgi?g=Detailed/$next.html&d=1">$next_title</a>~;
}
if ($prev) {
$prev_url = qq~<a href="$CFG->{db_cgi_url}/page.cgi?g=Detailed/$prev.html&d=1">$prev_title</a>~;
}
return { next_url => $next_url, prev_url => $prev_url };
}
You have to call it a little differently:
Code:
<%global_name($ID)%>Then it will give you <%next_url%> and <%prev_url%>
I've tested it on my test install and it works perfectly:
Code:
NEXT: <a href="http://gossamer.ultranerds.co.uk/cgi-bin/page.cgi?g=Detailed/266.html&d=1">SimpleDesign</a> PREV: <a href="http://gossamer.ultranerds.co.uk/cgi-bin/page.cgi?g=Detailed/268.html&d=1">NaturalDesign</a>
Cheers
Andy
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!