Back to Top Link
Some content gets long. Would be nice to incorporate a "back to top" link. I came up with this one, which seems to work, but I'm wondering if something more elegant and/or simple could be used.
All mods in _main.php
<body id="top"> [color=blue]<--- bookmark at page top[/color]
[color=blue](then, at bottom of the page, usually with the navigation control[/color]
<a class="top" href="#" data-code="?php
if ($_SERVER['QUERY_STRING'] == "" ) { echo '/'; } else {
echo '/?'.str_replace("&","&",$_SERVER['QUERY_STRING']); }
?>#top" title=" top of page ">[ Back to Top ]</a>
<?php echo '<a href="'.$ReqURI.'#top">[ '.T_('Back to top').' ]</a>'; ?>
Greyed out Navigation Controls
I've had a pet peeve since I first signed up with b2evo. It's got to do with the navigation controls "<previous || next>". When you're at the end (or the beginning) ... there isn't a "" and then the centered thing bounces around and all you see is the other one.
Anyway ... I solved it on randsco (sidebar) by underlaying an image, not using nav_links(), and previous_posts_link() and next_posts_link() instead. I then positioned the image pixel-perfect, which took a LOT of work ... just so the thing always shows "<prev" and/or "next>", when you're at the end or the beginning AND the other ones stay rock solid, alone or together.
So ... the short of it is, I found A way to test for presence of either the end or the beginning and do it all with TEXT, instead of pixel-perfect images. I quite like it. It's deployed on randsco at the BOTTOM of the page.
The code:
<div id="bNav">
<?php [color=blue]if( empty($p) && ($paged < 2) ) {[/color]// this is not the inverse of [color=green]if ( empty( $p ) && ( $paged > 1 ) ) {[/color] ;)
echo '<span> < Newer Entries </span>';
} else {
previous_posts_link('< Newer Entries '); }
?>
|
<?php $max_page=0;
if (!$max_page) $max_page = $MainList->get_max_paged();
if (!$paged) $paged = 1;
$nextpage = intval($paged) + 1;
//echo $max_page;
//echo $nextpage;
if ($nextpage == $max_page+1) {
echo '<span> Older Entries > </span>';
} else { next_posts_link(' Older Entries >'); } ?>
</div>
You have an error in your logic (blue above) and you can compress all the last bit ;)
<div id="bNav">
<?php if ( empty( $p ) && ( $paged > 1 ) ) {
previous_posts_link('< Newer Entries ');
} else {
echo '<span> < Newer Entries </span>'; }
?>
|
<?php $max_page = $MainList->get_max_paged();
$nextpage = ( !$paged ? 2 : intval( $paged ) + 1 );
if ( $nextpage > $max_page ) {
echo '<span> Older Entries > </span>';
} else { next_posts_link(' Older Entries >'); } ?>
</div>
Is there a way to do either, better?
Recent Comments