logically it would go like this:
"If there is a page of older posts or a page of newer posts, out put
the section containing the previous and next page links."
$theme->prev_page_link and $theme->next_page_link force output, as if
they contain echos in the function instead of a simple return. That's
fine if you only want to output a single link, but useless for
conditionally driving a larger section of HTML.
Does anybody know a way of doing what I want?
I appreciate any help. Thanks.
Is something like this what you're after, from the Connections theme:
<?php if ( $previous = $post->descend() ): ?>
<div class="previous">
« <a href="<?php echo $previous->permalink ?>" title="<?php
echo $previous->slug ?>"><?php echo $previous->title ?></a>
</div>
<?php endif; ?>
<?php if ( $next = $post->ascend() ): ?>
<div class="next">
<a href="<?php echo $next->permalink ?>" title="<?php echo
$next->slug ?>"><?php echo $next->title ?></a> »
</div>
<?php endif; ?>
--
Michael C. Harris, School of CS&IT, RMIT University
http://twofishcreative.com/michael/blog
IRC: michaeltwofish #habari
On Dec 22, 4:44 pm, "Michael C. Harris" <michael.twof...@gmail.com>
wrote:
Ah, sorry, I misunderstood (or didn't really concentrate while reading).
$theme->prev_page_link and $theme->next_page_link are theme functions[1]. You
can get a return value without echo by adding _return to the end of
the call, like
$theme->prev_page_link_return(). But I don't think you really want that.
This snippet is from the core theme mzingi.
<?php $theme->prev_page_link('« ' . _t('Newer Posts')); ?> <?php
$theme->page_selector( null, array( 'leftSide' => 2, 'rightSide' => 2
) ); ?> <?php $theme->next_page_link('& raquo; ' . _t('Older
Posts')); ?>
That seems to me to do what you're asking. If there is no previous page of
posts, 'Newer Posts' is not printed. Likewise next page. Let me know if that's
not doing what you're after and I've misunderstood again.
[1] See http://wiki.habariproject.org/en/Dev:Theme_Functions for an
explanation of theme functions, though the _return part is not
currently documented there.
On Dec 22, 5:32 pm, "Michael C. Harris" <michael.twof...@gmail.com>
wrote:
> Ah, sorry, I misunderstood (or didn't really concentrate while reading).
>
> $theme->prev_page_link and $theme->next_page_link are theme functions[1]. You
> can get a return value without echo by adding _return to the end of
> the call, like
> $theme->prev_page_link_return(). But I don't think you really want that.
>
> This snippet is from the core theme mzingi.
>
> <?php $theme->prev_page_link('« ' . _t('Newer Posts')); ?> <?php
> $theme->page_selector( null, array( 'leftSide' => 2, 'rightSide' => 2
> ) ); ?> <?php $theme->next_page_link('& raquo; ' . _t('Older
> Posts')); ?>
>
> That seems to me to do what you're asking. If there is no previous page of
> posts, 'Newer Posts' is not printed. Likewise next page. Let me know if that's
> not doing what you're after and I've misunderstood again.
>
> [1] Seehttp://wiki.habariproject.org/en/Dev:Theme_Functionsfor an
In that case, I think I finally understand what you were asking. I
must need coffee.
--
" if($theme->prev_page_link_return() != NULL or $theme-
>next_page_link_return() != NULL){ "
That always trips as positive. even when the don't seeme to return
anything. I also tried !="", that had no change.
On Dec 22, 5:43 pm, "Michael C. Harris" <michael.twof...@gmail.com>
wrote:
Hmm, it's actually returning an array with the name of the theme as
the key and null as the value, which is not what I expected. This
works, but since I don't know why it's returning that, it might be
flaky.
$prev = $theme->prev_page_link_return();
$next = $theme->next_page_link_return();
if($prev[$theme->name] != NULL or $next[$theme->name] != NULL){
// your html here
}
I'll try to get someone who knows this part of the code better than me
to explain what's going on, and if there's a better way.
Then again I learned programing 20 years ago as a hobby. Object
oriented coding has all ways seemed screwy to me. I have never seen a
object do something simpler or easier than a function returning an
array.
On Dec 22, 6:46 pm, "Michael C. Harris" <michael.twof...@gmail.com>
wrote: