I am migrating an old EE site to Craft. The EE site has a filter feature for certain weblogs. It outputs a list of entries for a weblog filtering on year, program, etc... which are passed as URL parameters.

I'd like to continue doing the same on the Craft site. I've setup custom routes to handle the url parameters. The following for example:

custom route examples with and without pagination url segment

With {% paginate %} using something that looks like this (a bit simplified):

{% paginate craft.entries.section('videos').limit(10).order(fSort).date(fYear).relatedTo(fCategory).relatedTo(fProgram) as pageInfo, pageEntries %}

<div class="pagination">
  {{...various pagination links using pageInfo...}}

<ul class="videolist">
  {% for entry in pageEntries %}
  <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
  {% endfor %}

The initial page of entries and pagination links outputs fine. But when going to subsequent pages via a pagination link (e.g., adding "p2" at the end of the URL), it can't find the route.

Does native pagination not work with custom routes? I tried different tokens for the pagination segment, but nothing seems to work.

  • 1
    I wonder if your route ending in page is causing trouble, because I definitely have a working custom route with functional, native pagination. Have you experimented with the pageTrigger setting? You might as well share some of the attempted (and not working) paging URLs you've tried just for good measure.
    – Matt Stein
    Jun 8, 2017 at 17:08
  • I'm with @MattStein... my guess is it's conflicting with the default pageTrigger config setting value.
    – Brad Bell
    Jun 8, 2017 at 22:50
  • Good to know it is supposed to work @MattStein, but does your case specifically involve dynamic url tokens? I had it set up initially without a second custom route with page, but that is when I noticed the issue - so added it to test it (without luck). I have modified the pageTrigger. No difference. If there are url parameters, it won't work. If there are no url parameters, it works. Seems to be a conflict with custom route dynamic url tokens and url pagination. I do see a weird error in the logs, so in the process of debugging this to see if it impacts this issue.
    – Nomad Guy
    Jun 9, 2017 at 15:38
  • It does indeed @NomadGuy, the only differences between yours and mine are fewer tokens overall and that my rules are defined in config/routes.php. It sounds like this could also come down to your server configuration if URL parameters are problematic. If you're still stuck, you might add more details about your server setup, various URL attempts, and definitely the weird error from the logs. This should very much be working.
    – Matt Stein
    Jun 9, 2017 at 17:31
  • I think I might have figured out what the issue pertains to. I have been testing with different amount of number tokens and what those values are. It seems like the pagination breaks if one or more of the url segments are set to "0". Though I don't see a clear pattern as to the sequence and number of 0's that will trigger it.
    – Nomad Guy
    Aug 5, 2017 at 1:20


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.