Pagination Object Gives Double Slashes Going From Page 1 to Page 2

#1

When paginating content, the nextPageURL() for Page 2 (when requested while on the 1st page) has doubles slashes before the page: portion. I would expect it to have only 1 slash (which is what all other pages have).

I would expect the search//page to simply be search/page.

For example, the Kirby website exhibits the same problem that I’m having on my site.

https://getkirby.com/search?q=text

The link for Page 2, is:

https://getkirby.com/search//page:2?q=text

But then Page 3 looks normal.

https://getkirby.com/search/page:3?q=text

And going back to Page 2 (from 3) looks normal.

https://getkirby.com/search/page:2?q=text

It’s unclear to me why, specifically, going from Page 1 to Page 2 would cause this issue. Is this a bug?

0 Likes

#2

On the getirby.com site, it only happens on the search page, though, not on the showcase or blog pages. It definitely does not look right.

I wonder if this has to do with the query syntax. Do you experience this issue with all paginated pages?

0 Likes

#3

Maybe its 2 things working together? If you are forcing slashes on the end of URLS via .htaccess for SEO purposes (ie to eliminate duplicate content) and if the pagination always prepends a slash, you are going to end up with two I guess.

Are you doing anything like that? Strange that it doesn’t happen when you move back and forth though.

0 Likes

#4

I only have one type of paginated page (site-wide search) at the moment.

My controller for search.php resembles:

$haystack = $site->index()->filter(function($p) use ($ignoreURIs, $ignoreTemplates) {
    
    return /* conditional statements here */ true;
});

$resultsPerPage = $page->resultsPerPage()->int() ?: 10;

$searchQuery = get('q');
$results = $haystack->search($searchQuery);
$results = $results->paginate($resultsPerPage);

$pagination = $results->pagination();

The usage in the template is basically boilerplate usage.

In regards to @jimbobrjames concerns: my site doesn’t append slashes at the end of the URLs (nor does it actively try to strip slashes).

0 Likes

#5

One more question: Did this issue only occur after updating? If so, with what version?

I did a quick test in a 2.5.7 Starterkit and the issue seems to appear only in combination with query parameters.

0 Likes

#6

Unfortunately, not sure. I only added pagination today, so I had already upgraded to 2.5.7 before even experimenting.

0 Likes

#7

Does not seem to happen with 2.5.6, only 2.5.7.

I created an issue on GitHub:
https://github.com/getkirby/kirby/issues/620

0 Likes