ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Isaac Raway


You must be logged in to post.

Pagination support?



Does this plugin support pagination?

We’ve got a site that heavily makes use of a variable number of sub-category URLs, for example, URLs might look like:

  • /shop/storage/ssd (category page)
  • /shop/storage/ssd/product-abc (product detail page)
  • /shop/storage/ssd/samsung (category page, showing all Samsung products within category)
  • /shop/storage/ssd/P20 (sub-category page, with pagination)
  • /shop/storage/P20 (root-category page, with pagination)

Can router pull this off? Our templates are currently a mess trying to handle this, so I was starting to knock up my own plugin to handle it but if Router does it, I’ll save myself the work.

# 1

Router should have no impact on pagination handling, although you do need to actually match on the P### segment for it to pick up the URLs correctly. Something like this should work to match:

^shop/(?P<cat1>.+)/(?P<cat2>.+)/(P)?(?(3)\d+)/*$ = "shop/_category_listing" 

When working on this I highly recommend something like RegexBuddy (there are similar online tools) to make debugging the pattern easier.

Note that I don’t think you actually have to save the value of the P### segment, just match on it so you get to the right template. It should be picked up by the Channel Entries tag on it’s own.

# 2

Almost sold, one followup.

How would router know using my example if a category page should be shown or the single entry (product detail) page?

I’m thinking that router wouldn’t know, so I’d have to have that logic within the category listing page on whether or not a single entry template should be used?

# 3

Correct that logic would be in your template - router wouldn’t really know the difference if the regex pattern for the two pages is the same. You could include special slugs in the URL such as “cat” that would be used in the pattern to detect which it is.