larry98765
Registered
Hi All,
I've set up an array ($links) representing a list of links, and would like to loop over the list, create the links, and when I hit the current page ($page)
find out what the prev() and next() items are in the array so I can create previous and next links.
Problem: When I'm on the first page ("brochures") I don't get a next link, even though on the last page ("stationery") I DO get a previous link.
Can someone help my find the error of my ways?
I've set up an array ($links) representing a list of links, and would like to loop over the list, create the links, and when I hit the current page ($page)
find out what the prev() and next() items are in the array so I can create previous and next links.
Problem: When I'm on the first page ("brochures") I don't get a next link, even though on the last page ("stationery") I DO get a previous link.
Can someone help my find the error of my ways?
PHP:
#my array
$links=array(
'brochures' => 'Brochures & collateral',
'webdesign' => 'Web design & site management',
'logodesign' => 'Logo design & corp. identity',
'stationery' => 'Stationery systems'
);
PHP:
function ls_linklist($links,$page) {
global $nextpage;
global $prevpage;
foreach($links as $link=>$description) {
if ($page==$link) {
$linklist .= "<li class=\"current\"><a href=\"$self?page=$link\">$description</a></li>\n";
#do the cha-cha-cha!
if (prev($links)) {
$prevpage=key($links);
next($links); #return to the current position
}
if (next($links)) {
$nextpage=key($links);
prev($links); #return to the current position
}
} else {
$linklist .= "<li><a href=\"$self?page=$link\">$description</a></li>\n";
}
next($links); #advance
}
echo $linklist;
}