Jump to content

Solved: Pagination Setup (Yet another)


ptjedi
 Share

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:

Home

  • 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:

/path/to/url/page3

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

Thanks in advance!

Link to comment
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.

Link to comment
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
Link to comment
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.

Link to comment
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!

Link to comment
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
Link to comment
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();
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...