RJM62
Touchdown! Greaser!
- Joined
- Jun 15, 2007
- Messages
- 13,157
- Location
- Upstate New York
- Display Name
Display name:
Geek on the Hill
I had a few professional coders tell me this was a convoluted and expensive way of styling the link for the current page in a database-driven pagination menu. I find it hard to understand how it could be much easier.
The current page and its database id are known, so I set the id for the row corresponding to that URL as "$thisPage." There's also a CSS class "current" to style that link. So when the iterator comes around to that page, it echoes "<li class = "current">" rather than "<li>".
I've been doing it this way for years, and I really don't think it's all that expensive. Am I wrong?
Thanks,
Rich
The current page and its database id are known, so I set the id for the row corresponding to that URL as "$thisPage." There's also a CSS class "current" to style that link. So when the iterator comes around to that page, it echoes "<li class = "current">" rather than "<li>".
PHP:
if($i == $thisPage) {
echo " <li class=\"current\"><a href=\"" . $friendlyURL . "\" title = \"". $title . "\">" . $i . "</a></li>\n";
} else {
echo " <li><a href=\"" . $friendlyURL . "\" title = \"". $title . "\">" . $i . "</a></li>\n"; }
$i++;
}
I've been doing it this way for years, and I really don't think it's all that expensive. Am I wrong?
Thanks,
Rich