Jump to content

Solved: Pagination Setup (Yet another)

Recommended Posts

Hi everyone,

Sometime since I posted something here, but I can't seem to be able to surpass this problem on my own. I've read a bunch of topics that relate to this problem but nevertheless, I fail to fix this pagination display.

Let me explain and hope someone help me out.

This is my current structure:


  • Catalog
    • Catalog (subpage, same type)
      • Product 1
      • Product 2
      • ...
      • Product N

The script is triggered in the first 'Catalog' in the tree above. The template of this script is similar to the default search.php, where the results are packed into the $out variable and dumped at the end. I don't believe this has anything to do with my problem.

At the beginning I have:

$query = "limit=3";
$products = $page->get("name=produtos")->children($query);
$count = count($products);

It returns the correct number of items, and displays the first 3.

At the end, I have the pager rendering:

echo $jogadores->renderPager(); 

And it displays the correct number of pages. However, clicking one of the links, the page refreshes with a new URL, but with the same three results. The URL looks like this example for page 3:


I have turned the "Allow Page Numbers?" on the 'catalog' template, so it should work.

Thanks in advance!

Share this post

Link to post
Share on other sites

Another thing that may help:

If I type in the template

echo $input->pageNum;

The result is always one.

I don't know what to do. I am this close to create my own pagination based on input attributes, but I rather use PW built-in functions.

Share this post

Link to post
Share on other sites

Have you tried using find?

$products = $page->find("parent=/produtos/, limit=3");

Or is there any other page->find with limit happening in your templates? This could inteferer with this and should use "start=0" in selector I think.

  • Like 1

Share this post

Link to post
Share on other sites

Thanks for the answer, Soma.

I had already tried with find, but the results are the same. However, I do have some other page->find, but they relate to other things (like setting up some options in a filter-menu). I've just deleted them, but the problem persists.

Share this post

Link to post
Share on other sites

I just found out what was going on. Since I am using the module LanguageLocalizedURL, I must activate the pagination flag in the translation template (the plugin author calls it the 'gateway').

Also, using page->find din't work, but the method in the first post does!

^_^ thank you!

Share this post

Link to post
Share on other sites

Yeah, when you use LanguageLocalizedURL module you should mentioned that as it makes it quite different. The page find method works, but maybe you'd need to set the parent path correctly. Glad you figured.

  • Like 1

Share this post

Link to post
Share on other sites

When using pagination, make sure you set "start=0" on any other non-paginated, DB-selector based calls that include a "limit=n" in them. Otherwise it'll attempt to paginate those too.  

  • Like 1

Share this post

Link to post
Share on other sites

Hmm. I'm having the same problem, but it's the only "limit=n" call on the page, and I'm not using LanguageLocalizedURL, either. I've never used the pager before, though... I must be making some obvious mistake here?

[Edit] Yes, it was a very obvious mistake. :) I somehow skipped the part where you have to enable pagination in the URLs section for the template. 

$news = $pages->get("/news/")->children("limit=3");
foreach($news as $newspost) {
	echo "<div class='post'><h2>".$newspost->title."</h2>";
	echo "<p class='newsdate'>".date('M j, Y',$newspost->created)."</p>";
	echo $newspost->body."</div>";
echo $news->renderPager();

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Peter Troeger
      Hello Community 🙂
      Has anyone ever tried having multiple elements on one page that get their info with $pages->find('selector, limit=n') and tried using pagination on one of these elements without effecting the other?
      I have a slider on a page where I display content with pagination. But when I go to page two, the slider content also goes to page two, which I don't want it to do 🙂
      Any tips are greatly appreciated!
    • By Peter Troeger
      Hello 🙂
      I have set up pagination on a mulitlanguage site.
      I've done this before, but this time I have a problem I can't solve.
      Pagination is activated on 'parent-template' and 'child-template' just to be sure 🙂
      This is my code:
      $children = $page->children('limit=1'); foreach($children as $child) { $title = $child->title; echo $title; } echo $children->renderPager(); The navigation is output correctly and the link look correct as well 'parent-page/page2/'.
      But when I click the link, the site seems to redirect back to 'parent-page/
      Any help would be greatly appreciated 🙂
      - Peter
    • By MateThemes
      Hello everyone!
      I have a problem with pagination. I have following code:
      <div class="uk-section"> <?php $results = $pages->find("template=gallery, limit=10, sort=title"); $pagination = $results->renderPager(); echo $pagination; echo "<ul class='uk-pagination uk-flex-center'>"; foreach($results as $result) { echo "<li><a href='{$result->url}'>{$result->title}</a></li>"; } echo "</ul>"; echo $pagination; ?> </div> Which works fine. And this markup results in following html code:
      <div class="uk-section"> <ul class='uk-pagination uk-flex-center'> <li> <a href='/galerie-bisheriger-projekte/'>Galerie bisheriger Projekte</a> </li> <li> <a href='/galerie-bisheriger-projekte/galerie-1/'>galerie-1</a> </li> </ul> </div> But instead of "Galerie bisheriger Projekte" and "galerie-1" I want to have a number.
      And as last question, how can I add a previous and next button?
      Thanks for your help!
    • By Liam88
      Hi all,
      Quick question as I haven't found anything from my Googling. 
      I have a blog on the site which utilises pagination. On the standard blog page I have a custom header which has featured posts.
      Below that I then have recent posts like mosts blogs.
      Now if i click to page two or three I want the header to disappear and just show a continuation of the standard posts.
      I'm not sure how to go about this so any direction would be helpful.
    • By stanoliver
      Good morning everyone!
      I have a growing number of posts about cars, bikes, airplanes, etc. 
      The following code (below) just works fine and returns only the posts of the category=cars as I desired together with pagination.
      In my url I have for example /categories/cars/car1 or /categories/bikes/bike1
      I do want to filter my posts not only with ... category=cars ... but also with category=bikes or category=airplanes and at best:
      If my url is /categories/bikes/ then ... category=cars ... should be overwritten or replaced by ... category=bikes ... 
      If my url is /categories/airplanes/ ... then the filter should be ... category=airplanes ... (I know a work around by creating almost identical templates where I could just change the "category=cars" part of my code but that's comes of a prize by repeating a lot of identical code and is not a good habit). In the documentation I read something about the "has_parent" selector but I could not get to work it related to the urls mentioned above.
      <?php foreach ( $results = $pages->find('id>1, template=templateblogpost, category=cars, limit=5, sort=-postdate') as $post 😞?> <!-- Blog entry --> <div class="g8-card-4 g8-margin g8-white"> <!--<img src="/g8images/bridge.jpg" alt="Norway" style="width:100%">--> <div class="g8-container"> <h3><b><?= $post->title; ?></b></h3> <h5>Datum: <span class="g8-opacity"><?= $post->postdate; ?></span></h5> </div>   <div class="g8-container"> <p><?= $post->posteditor; ?></p> <div class="g8-row"> <div class="g8-col m8 s12"> <p> <a href="<?= $post->url; ?>"><button class="g8-button g8-padding-large g8-white g8-border"><b>Details lesen &raquo;</b></button></a> </p> </div> <div class="g8-col m4 g8-hide-small"> <!--<p><span class="g8-padding-large g8-right"><b>Comments &nbsp;</b> <span class="g8-badge">2</span></span></p>--> </div> </div> </div> </div> <!-- END BLOG ENTRIES --> <?php endforeach; ?>   <? echo $results->renderPager(array( 'nextItemLabel' => "rückwärts", 'previousItemLabel' => "vorwärts")); ?>
  • Create New...