carminejg3, I am doing that with my site and it works nicely. I'll try to document what I have, it might help you.
I have a global called 'nextprev' which is included in detailed.html just after the body tag as <%nextprev%>. This global contains:
Code:
sub {
my $args=shift;
#my $cat_id = $IN->param('catID');
my $db = $DB->table ('Category','CatLinks');
my $cat_id = $db->select ( { 'CatLinks.LinkID' => $args->{ID} }, ['Category.ID'] )->fetchrow_array;
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' ,'Links.Title'] );
my ($next, $prev, $next_title, $prev_title, $Title);
while (my ($id,$title) = $sth->fetchrow_array) {
if ($id == $args->{ID}) {
($next,$next_title) = $sth->fetchrow_array;
last;
}
else {
$prev = $id;
$prev_title = $title;
}
}
my ($next_url, $prev_url);
if ($next) {
$Title = $next_title;
$Title =~ y/ \t\r\n?"'#/-/d;
$next_url = "/detail/$Title-L$next.html";;
}
if ($prev) {
$Title = $prev_title;
$Title =~ y/ \t\r\n?"'#/-/d;
$prev_url = "/detail/$Title-L$prev.html";;
}
return {next_url => $next_url, next_title => $next_title, prev_url => $prev_url, prev_title => $prev_title};
}
Then, where I want the next previous links to display I use this piece of code:
Code:
<%if $prev_url%>
<p>Previous link: <a href="<%prev_url%>"><%prev_title%></a></p>
<%endif%>
<%if $next_url%>
<p>Next link: <a href="<%next_url%>"><%next_title%></a></p>
<%endif%>
I'm not sure if that will help you but it might give you something to go on.