Topic: Previous / next links missing

Really pleased with this upgrade process - changing from 0.6.0 to 0.7.3 has been the simplest upgrade process yet, great work!

The only minor problem I've spotted with the whole process is that my next/previous links have vanished from one of my layouts for some reason.

Here's the code I was using...

<div class="postnav">

    <?php if ($previous = $this->previous()): ?>
        &#171; <?php echo $previous->link(); ?> &#124;
    <?php endif; ?>
    
<a href="<?php echo URL_PUBLIC; ?>">Home</a>
                            
        <?php if ($next = $this->next()): ?>
    &#124; <?php echo $next->link(); ?> &#187;
    <?php endif; ?>

</div>

Any idea why this might have broken guys?

Huge thanks again, I love Wolf more and more with each version smile

Thumbs up

2

Re: Previous / next links missing

Hi Valeska! Glad the upgrade went smoothly.

Valeska wrote:

Any idea why this might have broken guys?

The short answer is "yes".

Slightly longer answer: the previous/next functions were recoded to reflect page position rather than creation dates (in this precise commit, lines 181-191 if you're curious). Eminently sensible change (imo!).

But ... this means that until your pages have a "position" (which they won't, unless they've been reordered), they will just give you a blank ... as you have discovered.

And now so have I, btw, so thanks for flagging this up. Hopefully we can put our heads together and work out a solution for upgraded sites. My quick test suggests that the "position" number created by the page drag-drop is a bit flakey.

So, some further tests are needed. Watch this space!

Re: Previous / next links missing

Thanks David.

Makes complete sense why it was changed.

Ironically though this was a quick way for me to click through my pages particularly after upgrades. So that's how I noticed it.

Would be great if there could be a fix, but I appreciate this is a pretty fundamental change to the way things have worked previously.

Thumbs up

4

Re: Previous / next links missing

I've done a bit of playing with this Valeska -- one option (not a great one, and not a long term solution over all) would be to revert to the old "previous/next" functions, if you do not re-order your pages, and are happy for the ordering to be based creation date rather than on position.

Shoot me a forum email if you're interested. Meanwhile we'll keep chipping away at a more robust solution!

Re: Previous / next links missing

Why not try mimicking the previous function?

<div class="postnav">
    
    <?php
    if ($this->parent)
        $previous = $this->parent->children(array(
            'limit' => 1,
            'where' => 'page.id < '. $this->id,
            'order' => 'page.created_on DESC'
        ));
    
    if ($this->parent)
        $next = $this->parent->children(array(
            'limit' => 1,
            'where' => 'page.id > '. $this->id,
            'order' => 'page.created_on ASC'
        ));
    ?>
    
    <?php if ($previous): ?>
        &#171; <?php echo $previous->link(); ?> &#124;
    <?php endif; ?>
    
<a href="<?php echo URL_PUBLIC; ?>">Home</a>
                            
        <?php if ($next): ?>
    &#124; <?php echo $next->link(); ?> &#187;
    <?php endif; ?>

</div>

Note that its untested, but should give you similar functionality.

Cheers,

Tyler

Re: Previous / next links missing

Note that David and I had an "off line" discussion about this. The main problem is not particularly that the previous() / next() functions work somehow but rather what the correct behaviour should be. (everyone seems to have different ideas on that)

We've come to an initial idea yesterday and will refine it somewhat. We'll probably post it for comments soon-ish.

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution.