Jump to content

Pagination don't work


ShadowByte
 Share

Recommended Posts

Hello everybody,

I have a problem with my pagination.

This is what I have in my Template:

if($news->hasChildren()) {
	$newsItems = $news->children("limit=2, sort=-date");
	foreach($newsItems as $newsItem) {
?>
...
<?php
	}
}

$pagerOptions = ['numPageLinks' => 10,
                 'nextItemLabel' => '<i class="ti-arrow-right"></i>',
                 'previousItemLabel' => '<i class="ti-arrow-left"></i>',
                 'listMarkup' => "<ul class='pagination mt-70 justify-content-between d-flex'>{out}</ul>",
                 'itemMarkup' => "<li class='page-item {class}'>{out}</li>",
                 'linkMarkup' => "<a href='{url}' class='page-link b-0 bs-none width-50 mx-3 height-50 bg-dark bg-dark2-hover d-flex align-items-center justify-content-center white'><span>{out}</span></a>",
                 'currentItemClass' => "active",
                 'firstItemClass' => "mr-auto page-link b-0 bs-none width-50 mx-3 height-50 bg-dark bg-dark2-hover d-flex align-items-center justify-content-center white",
                 'lastItemClass' => "ml-auto",
                ];
echo $newsItems->renderPager($pagerOptions);
?>

....

The pagination itself is displayed correctly.
To test it, I created 3 news items and set the limit to 2. So there should be 2 pages. This is also displayed correctly by the pagination.

But if I now click on the link for the second page, the news from the first page is displayed.

Did I miss something?

Thanks in advance

EDIT:

The link in the pagination is created correctly.

..../news/?page=2

 

Link to comment
Share on other sites

Ok, I found the problem. I had to activate the option "Allow Page Numbers" in the parent template, not in the child template.

But another question.

I would like to have links like this:

..../news/page/2

After some testing I have links like this now.

..../news/page2/

How can I get links like in my first example?

This is my actual configuration from the template:
 

727183636_Screenshot2023-12-06at20-33-37EditTemplatenewssitefgfc820_de.thumb.png.e4ac1227cb23b430c4df21956668ab86.png

Link to comment
Share on other sites

Why do you want to do that?

You can configure that via $config->pageNumUrlPrefix, but what you are trying to do is not possible by default (and maybe not a good idea at all). By adding the slash you basically let it look like another layer of the pagetree (or of your sitemap), but that's not the case, so I'd say it's logically incorrect. Also see here:

 

  • Like 1
Link to comment
Share on other sites

You should try put it in site/config.php. I see that LanguageSupportPageNames uses $config->pageNumUrlPrefix so I'm not sure if it needs more configuration. It looks like in source code that if you don't define it for every language it will use the one from config.

Link to comment
Share on other sites

1 minute ago, da² said:

You should try put it in site/config.php. I see that LanguageSupportPageNames uses $config->pageNumUrlPrefix so I'm not sure if it needs more configuration.

I tried to set the prefix in site/config. It didn't work. I changed the prefix in the module and now it works.

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...