Forum
Issue getting next/prev buttons working
Sorry but PHP isn't my strong suit and I've been having trouble converting the next/previous solutions article to blog posts.
I can't get my template to show up on the page and I'm not really sure what I'm doing wrong. :(
This is my php
<?php
perch_blog_custom(array(
'sort'=>'postDateTime',
'sort-order'=>'DESC',
'value' => $result[0]['_sortvalue'],
'template'=>'blog/post.html',
'count'=>1,
'skip-template' => true,
'return-html' => true,
));
PerchSystem::set_var('is_next', true);
perch_blog_custom(array(
'template' => 'blog/post_comic_page_navigation.html',
'filter' => '_order',
'match' => 'gt',
'value' => $result[0]['_sortvalue'],
'sort' => '_order',
'sort-order' => 'ASC',
'count' => 1,
));
PerchSystem::set_var('is_prev', true);
perch_blog_custom(array(
'template' => 'blog/post_comic_page_navigation.html',
'filter' => '_order',
'match' => 'lt',
'value' => $result[0]['_sortvalue'],
'sort' => '_order',
'sort-order' => 'DESC',
'count' => 1,
));
echo $result['html'];
?>
And this is my template...
<div class="comic-navigation">
<ul class="comic-navigation__main-nav">
<perch:if exists="is_prev"><li><a class="comic-navigation__previous" href="?s=<perch:content id="slug" type="slug" />">Previous</a> </li></perch:if>
<perch:if exists="is_next"><li><a class="comic-navigation__next" href="?s=<perch:content id="slug" type="slug" />">Next</a></li></perch:if>
</ul>
<p class="comic-navigation__secondary-nav"><a href="">First</a> | Page 30 | <a href="">Latest</a></p>
</div>
You're not populating
$result
anywhere. This:should be:
Thanks Drew, that fixed them not displaying. Unfortunately I'm still having trouble getting it to work the way I want.
Currently my previous button is displaying the first post, instead of the actual previous post and my next button is showing the most recent, instead of the next one. :S
My new php...
Don't think it's important but just incase my post_comic_page_prev.html...
and the post_comic_page_next.html
Change:
to
And change:
to
Woo thanks Drew!
Sorry I thought it was fixed and marked it as solved but it's still not quite working so I started another thread
https://forum.grabaperch.com/forum/01-10-2015-nextprev-buttons-still-not-working-correctly