OllieMackJames Posted January 4, 2014 Share Posted January 4, 2014 I am using the following code on a page to get pagination that will be used by infinitescroll to append paginated pages to the current page. Trouble I run into is that the pagination does not work properly, it just keeps adding/appending the same page over and over once I scroll to the bottom. So there must be something that I am doing wrong with the pagination call, can anyone see my mistake: <div id="wrapper" class="clearfix"> <?php $limit = 7; // the "limit"-setting used on this page $results = $pages->find("template=blogpost-iframe, limit=$limit, start=0"); foreach($results as $result) { $imgURL = $result->images->first()->url; // original image $thumbWidth = 192; $thumbWidthPX = $thumbWidth . 'px'; $thumb = $result->images->first()->size($thumbWidth); $thumbURL = $thumb->url; $siteURL = $pages->get(1)->httpUrl; // home URL $summary = $result->summary; $title = $result->title; $blogURL = $result->httpUrl; $frontSummary = $result->frontSummary; echo <<<BLOGEOF <div class="tack"> <div class="tackHolder"> <div class="actions"> <div class="left"> <a class="button" href="http://pinterest.com/pin/create/button/?url=$siteURL/&media=$imgURL&description=$summary"><strong><em></em>Repin</strong></a> </div> <div class="left"> <div id="facebook_like_button_holder" > <a title="send to Facebook" href="http://www.facebook.com/sharer.php?s=100&p[title]=$title&p[summary]=$summary&p[url]=$blogURL&p[images][0]=$imgURL" target="_blank"><div id="fake_facebook_button" class="button"><strong><em></em>like</strong></div></a> </div> </div> </div> <a href="$blogURL" class="iframe cboxElement" title="$title"><img src="$thumbURL" alt="$title" title="$title" class="tack_img drthumbonly" width="$thumbWidthPX"/></a> </div> $frontSummary <p class="links"><a href="$blogURL" class="iframe cboxElement">Meer Informatie...</a></p> </div> BLOGEOF; } ?> </div> </div><!-- #wrapper --> <div class="clear"></div> <nav id="page-nav"> <?php $children = $page->children("limit=" . $limit); $totalpages = ceil($children->getTotal() / $limit); // PAGINATOR: set SEO tags for Google if ($input->pageNum) { if ($input->pageNum < $totalpages) { echo "<a href='" . $page->url . $config->pageNumUrlPrefix . ($input->pageNum + 1) . "'>Next "; } else { echo "Thanks for browsing, you have reached the bottom of this page!"; } } ?> </nav> Thanks! Link to comment Share on other sites More sharing options...
OllieMackJames Posted January 4, 2014 Author Share Posted January 4, 2014 Found it already myself: $results = $pages->find("template=blogpost-iframe, limit=$limit, start=0"); This threw the sytem off, I don't know why, but taking out start=0 did the trick. Would be nice to understand why and how this works, now I am guessing and through trial and error got to this solution. Does anybody know how and why this works and what the underlying logic is? thanks! Link to comment Share on other sites More sharing options...
adrian Posted January 8, 2014 Share Posted January 8, 2014 Have a read of the "Do I have to keep track of the page number?" section on this page: http://processwire.com/api/modules/markup-pager-nav/ If you decide to keep track of the page number yourself, you can change the starting position, but if you always set: start=0 then it will start at the first page each time it is called. 1 Link to comment Share on other sites More sharing options...
daslicht Posted January 12, 2014 Share Posted January 12, 2014 I also have a pagination issue here and created teh following test setup: Essentially I have the following 6 pages: About Site Map Admin MyArticle News Gallery the homepage template looks like this: <?php $results = $page->children("limit=3"); $pagination = $results->renderPager(); echo "<ul>"; foreach($results as $result) { echo "<li><a href='{$result->url}'>{$result->title}</a></li>"; } echo "</ul>"; echo $pagination; The displayed result looks like this: About Site Map Admin 1 2 Next So the paginator is rendered properly, but when I now click on one pagination link the page just refreshes? Do I have to implement the pagination logic myself using pageNum ? ~Marc Link to comment Share on other sites More sharing options...
Soma Posted January 12, 2014 Share Posted January 12, 2014 Have you enabled pagination on home template? Link to comment Share on other sites More sharing options...
adrian Posted January 14, 2014 Share Posted January 14, 2014 Here is apparently a working solution for Infinite Scroll in PW: http://processwire.com/talk/topic/5189-pagination-markup-question/?p=50019 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