- b2evolution CMS Support Forums
- Archives
- Older bugs
- Bugs in versions 0.x
- next_posts_link - BUG REMAINS
1 stk Feb 07, 2005 19:39
Graham pointed out this morning that our archive "more..." link fails. He suggested that we're missing the 'case' option for this, but that's not the case. Upon further inspection, it looks like a bug.
1) version 0.9.0.11
EDIT- Thought I had it solved, guess not. Whited out solution postings till it IS actually, really truly FIXED!
EDIT: STOP ... bug identified in _functions_bposts.php, see below
2) Using "previous_post_link" and "next_post_link" instead of "posts_nav_link". Back office settings are "posts paged", archive mode "monthly" & $posts set to 7 in the index.php file.
3) If one clicks the arcdirurl link on our [url=http://randsco.com]page[/url] you get the following error:
Fatal error: Call to a member function on a non-object /.../b2evocore/_functions_bposts.php on line 1048
4) If you look at that file, that's where the "next_post_link" function is defined. Here's the code, with line 1048 marked:
/**
* next_posts_link(-)
*
*
*/
function next_posts_link($label='#', $max_page=0, $page='')
{
global $p, $paged, $result, $request, $Settings;
if( $label == '#' ) $label = T_('Next Page').' >>';
if ($Settings->get('what_to_show') == 'paged')
{
global $MainList;
line1048>>> if (!$max_page) $max_page = $MainList->get_max_paged(); <<<<<line 1048
if (!$paged) $paged = 1;
$nextpage = intval($paged) + 1;
if (empty($p) && (empty($paged) || $nextpage <= $max_page))
{
echo '<a href="';
echo next_posts($max_page, $page);
echo '">'. htmlspecialchars($label) .'</a>';
}
}
}
5) If I put back the posts_nav_links option & take out the others, then the problem disappears & the arcdirurl works fine.
Here's the HTML code that calls the functions & arcdirurl link:
<h3><?php echo T_('Journal Archives') ?></h3>
<!-- <?php posts_nav_link(' | ','<newer posts','older posts>'); ?> -->
<div id="navLink">
<div id="newer"> <?php previous_posts_link('<newer posts'); ?> </div>
<div id="bar">|</div>
<div id="older"> <?php next_posts_link('older posts>'); ?> </div>
</div>
<ul>
<?php require( dirname(__FILE__).'/_archives.php' ); // ARCHIVES LIST INCLUDED HERE ?>
<li> <a href="<?php $Blog->disp( 'arcdirurl', 'raw' ) ?>" title="See the complete archives"> <?php echo T_('more...') ?> </a> </li>
</ul>
If anyone has any ideas about how to get around or FIX this, it would be GREATLY appreciated?? We really want to use the next/previous_posts_link (for formatting reasons).
Because I can't see anything wrong with the HTML code & we haven't modified either of these functions, I'm assuming that it must be a bug.
Thanks for anyone's help! :)
-Scott
Thought I had it fixed - I've whited out this post till problem identified
The reason that "posts_nav_link" WORKS, is because it sets the variable "$max_paged" correctly, THEN calls "next_posts_link". "next_posts_link" (line 1048) doesn't. The variable is spelled incorrectly as "$max_page" (not past-tense 'paged').
I went through "next_posts_link" and changed ALL of the occurrences of "$max_page" to "$max_paged" (there were 4) and it fixed the problem, though I suspect the first occurrence 'if(!$max_page)' is the only one that MUST to be changed, since $max_page is actually DEFINED right after that. (confirmed)
Anyhow ... THAT'S the problem. You can add this to your 'To-Do' list.
Cheers, Scott