ShadowByte Posted December 6, 2023 Share Posted December 6, 2023 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 More sharing options...
BitPoet Posted December 6, 2023 Share Posted December 6, 2023 Did you activate page numbers for your template? Link to comment Share on other sites More sharing options...
ShadowByte Posted December 6, 2023 Author Share Posted December 6, 2023 Yes, I activate this in the template from the children. Link to comment Share on other sites More sharing options...
ShadowByte Posted December 6, 2023 Author Share Posted December 6, 2023 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: Link to comment Share on other sites More sharing options...
bernhard Posted December 6, 2023 Share Posted December 6, 2023 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: 1 Link to comment Share on other sites More sharing options...
ShadowByte Posted December 7, 2023 Author Share Posted December 7, 2023 To test the prefix I set the "$config->pageNumUrlPrefix" to "p" in the "wire/config.php" but nothing changed after this. The link is still .../page2/ Why? Was it the wrong place to change the prefix? Link to comment Share on other sites More sharing options...
bernhard Posted December 7, 2023 Share Posted December 7, 2023 I've never tried it myself, but you should never change anything inside the /wire folder. Use /site/config.php instead Link to comment Share on other sites More sharing options...
ShadowByte Posted December 7, 2023 Author Share Posted December 7, 2023 I tested it in both config.php. But nothing changed. Link to comment Share on other sites More sharing options...
ShadowByte Posted December 7, 2023 Author Share Posted December 7, 2023 I found the problem. My page is multi language. So I have to change the prefix in the "LanguageSupportPageNames" Module. Anyone who can read has a clear advantage ? ?♂ 1 Link to comment Share on other sites More sharing options...
da² Posted December 7, 2023 Share Posted December 7, 2023 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 More sharing options...
ShadowByte Posted December 7, 2023 Author Share Posted December 7, 2023 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 More sharing options...
da² Posted December 7, 2023 Share Posted December 7, 2023 Strange, on my side it works in every language. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now