Jump to content

Pagination bug - disappearing content


Peter Knight
 Share

Recommended Posts

Wierd bug which my client just spotted...

I have a global footer on my site.

It's an include file pulling in three columns of page titles.

  • Col 1 = News headlines
  • Col 2 = PDF titles
  • Col 3 = Video titles

All three are pulled in via selectors (see below) and work perfectly across the site except for a paginated news page.

Here's the bug.

  • if you click Page 2, the footer Video titles disappear.
  • if you click Page 3 onwards, both the footer PDF titles AND the footer video titles disappear.

Here's my selectors...which work apart from p2 and p3

The main news feed

<?php
$pages->find("template=news_item, news_type=Investor News, sort=-news_date, limit=5"); 
$pagination = $results->renderPager();

foreach($results as $result) {
    echo "<div class=\"news-wrapper\">"; 
    echo "<h3><a href={$result->url}>{$result->title}</a></h3>";
    echo "{$result->news_summary}";
    echo "<div class=\"published-date\"><span class=\"icon-meta icon-calendar-1\">{$result->news_date}</span></div>";
    echo "</div>";
}      

echo $pagination; 

?>

The disappearing PDF selector

<?php
			
$studies = $pages->find("template=case-study, limit=4");
$out = "";
foreach ($studies as $study) {
  $out .= "<div class=\"home-casestudy-wrapper\">";
  $out .= "<span class=\"icon-meta icon-document\"><a href={$study->url}>{$study->title}</span></a>";
  $out .= "</div>";
}
echo $out;
?>

The disappearing video selector

<?php
$videos = $pages->find("template=video-detail, limit=5, sort=sort");
$out = "";
foreach ($videos as $video) {
   $out .= "<div class=\"home-vid-wrapper\">";
   $out .= "<span class=\"icon-meta icon-youtube-play\"><a href={$video->url}>{$video->title}</span></a>";
   $out .= "</div>";
}
echo $out;
?>

It seems specific to the pagination. Everything works on p1 and there are no debug errors displaying either.

Link to comment
Share on other sites

Quote from the docs :)
 

However, if you are viewing a paginated list on any page number greater than 1, and you find ProcessWire returning the wrong set of pages, then replace your "limit=n" selector with the following:

$pages->find("start=0, limit=n"); 

That will ensure that ProcessWire does not attempt to paginate the results of that function call when on page numbers greater than 1.

See: https://processwire.com/api/modules/markup-pager-nav/

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...