Alexander Posted February 6, 2013 Share Posted February 6, 2013 It would be nice to get something like this http://codex.wordpress.org/Next_and_Previous_Links Link to comment Share on other sites More sharing options...
Luis Posted February 6, 2013 Share Posted February 6, 2013 check this: http://processwire.com/api/modules/markup-pager-nav/ already built in Link to comment Share on other sites More sharing options...
Alexander Posted February 6, 2013 Author Share Posted February 6, 2013 I think, it used only for search result pagination. But I'm interested in between pages navigation. Ex. <- Previous post | Next post-> Link to comment Share on other sites More sharing options...
Luis Posted February 6, 2013 Share Posted February 6, 2013 nope, not for search only. I´ve used the pagination with prev - next buttons on this page: http://würfelhauskonzept.de/artikel/ Just read the pagination tutorial and the usage will be clear, very handy little module. Link to comment Share on other sites More sharing options...
Alexander Posted February 6, 2013 Author Share Posted February 6, 2013 Supergut. Vielen dank, Luis! Link to comment Share on other sites More sharing options...
Luis Posted February 6, 2013 Share Posted February 6, 2013 to give you a starting point, this is the code snippet from the page i´ve posted <?php include('./includes/head.php'); $options = array( 'nextItemLabel' => "Weiter", 'previousItemLabel' => "Zurück", 'listMarkup' => "<div class='pagination pagination-centered'><ul>{out}</ul></div>", 'currentItemClass' => "active disabled", 'itemMarkup' => "<li class='{class}'>{out}</li>", 'linkMarkup' => "<a href='{url}'>{out}</a>" ); $items = $page->children("limit=10"); $pagination = $items->renderPager($options); echo $pagination; ?> 1 Link to comment Share on other sites More sharing options...
Mats Posted February 6, 2013 Share Posted February 6, 2013 Try this: $page->next $page->prev http://processwire.com/api/variables/page/ 1 Link to comment Share on other sites More sharing options...
Luis Posted February 6, 2013 Share Posted February 6, 2013 yes mats is right, this is the normal prev next function. just thought you want a prev next and pages navigation. So you got 2 solutions now 1 Link to comment Share on other sites More sharing options...
Alexander Posted February 6, 2013 Author Share Posted February 6, 2013 Thanks Mats and Luis for your help and time. I trying to use $page->next, but in my case it returns only numbers. I findet in blog demo this code and it's work perfect. function renderNextPrevPosts($page) { $bedroom = $page->getUnformatted('bedroom'); $nextPost = $page->parent->child("bedroom>$bedroom, sort=bedroom"); $prevPost = $page->parent->child("bedroom<$bedroom, sort=-bedroom"); $out = "<div class='next-prev-posts'>"; if($prevPost->id > 0) $out .= "<p class='prev-post'><span><</span> <a href='{$prevPost->url}'>{$prevPost->title}</a></p>"; if($nextPost->id > 0) $out .= "<p class='next-post'><a href='{$nextPost->url}'>{$nextPost->title}</a> <span>></span></p>"; $out .= "</div>"; return $out; } Link to comment Share on other sites More sharing options...
Mats Posted February 6, 2013 Share Posted February 6, 2013 It returns the next page id. So you have to use $page->next->title to get the title ie. And a linked title: <a href='{$page->next->url}'>{$page->next->title}</a> 1 Link to comment Share on other sites More sharing options...
Luis Posted February 6, 2013 Share Posted February 6, 2013 to form a link you could do something like this <a href="<?php echo $page->next->url ?>">Next</a> Link to comment Share on other sites More sharing options...
Alexander Posted February 6, 2013 Author Share Posted February 6, 2013 Luis, maybe I'm wrong, but this solution does not support sorting of search result. Anyway, thanks! Link to comment Share on other sites More sharing options...
ryan Posted February 6, 2013 Share Posted February 6, 2013 The $page's next and prev functions return the next and previous sibling, according to whatever sort settings you have defined with the parent. However, you could still do it like this: $siblings = $page->siblings("sort=date"); // or whatever you want to sort by $next = $siblings->getNext($page); $prev = $siblings->getPrev($page); if($prev) echo "<a href='$prev->url'>Prev</a> "; if($next) echo "<a href='$next->url'>Next</a> "; Personally, I prefer using regular pagination to something like this. The skyscrapers profile has some good examples of using pagination with custom sorts. 2 Link to comment Share on other sites More sharing options...
Alexander Posted February 6, 2013 Author Share Posted February 6, 2013 Great, works perfect! Thanks Ryan! Better with title name. if($prev) echo "<a href='$prev->url'>$prev->title</a> "; if($next) echo "<a href='$next->url'>$next->title</a> "; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now