Jump to content

cant get my Pagination to work


benbyf
 Share

Recommended Posts

Hi,

trying to implemement a set of blog pages and started using the Pagination module to find I couldnt list the page=2 etc results. This is what I started with:

This is on a blog template, of which the post template children have page number enabled.

$results = $page->children()->find("limit=2, sort=-date");
$pagination = $results->renderPager();
echo $results->render();

This didnt produce different results when clicking 'next'.

so I tried:

$limit = 2;
if($_GET["page"]==0){
  $startNum = 1;
}else{
  $startNum = $_GET["page"];
}
$start = ($startNum-1) * $limit;
echo $start;
$results = $page->children()->find("start=$start,limit=$limit, sort=-date");
$pagination = $results->renderPager();
echo $results->render();

And it works up to a point but then starts doing some crazy stuff! (like adding a new number for another list page which doesnt exist, e.g. page=4 when the limit only allows for 3 pages of list).

any help would be amazing.

b

Link to comment
Share on other sites

hey, I had Allow on the child page template, so change for the blog template and that changed the pagination url links from /?page=2 ot /page2 and using this still not listing the next page (i.e. / and /page2 have the same content)

This is the site

$results = $page->children()->find("limit=2, sort=-date");
$pagination = $results->renderPager();
echo $results->render();
Link to comment
Share on other sites

Ok, well you have the allow pagination on the correct template now which is good.

I don't really ever use render() for generating page content, so I might be off here, but try this:

foreach($results as $result){
    echo $result->title . '<br />';
}
Link to comment
Share on other sites

thanks, but nothing seems to make the url /page2 list something else (there are 5 children of that blog page current with the limit of 2 so there should be 3 list page /, /page2, /page3)

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

×
×
  • Create New...