Better to use routing, javascript or something else to create links to paginated pages?


#1

So I have pagination on my blog page. I also have navigation where the main links are for years, and the subnavigation are for months (Ex. main nav item: 2018, subnav items: Jan, Feb, Mar, etc).

When one clicks on a month, I want the URL to change to whatever page, like clicking Mar would load page url/page:3

Because I’m a beginner coder, I’m not totally familiar with how the routing built into Kirby works, though I think if that’s the best way to do it, I can figure it out. So my question is what people would recommend for creating this kind of functionality. Kirby’s routing? javascript? Something else? Ideally, I don’t want to hard code any page numbers.

Thanks!


#2

Why would/should clicking on March lead you to pagination page 3? I mean, you want to paginate after a given number of pages, so if you filter by year and month, the first page of your pagination will still be one and you will only end up with more pagination pages if the number of articles in your filtered collection exceeds your set pagination limit.

You could use year and month as parameters, and the filter by those parameters, similar to filtering by tags. No JavaScript or routing needed, you just have to adjust the urls.


#3

Oh sorry, I should clarify that the way I’ve done the pagination is by grouping all posts by month and then each pagination shows a full month of posts rather than a set number of posts (like 31 posts).

Basically the site is a daily photo journal so the structure of the site is there’s a new page for each year and each year page has a subpage for every day of the year (a new post every day). So in the year view you’re able to see every day of that year (you can picture it like google photos or instagram if add a new photo every day). Except unlike google photos and instagram, there’s a subnav item for each month where when it’s clicked, I want to filter these posts to only show posts dated as the selected month.

I don’t think I’ve tried filtering by parameters so I’ll give that a try and come back if it doesn’t solve my problem! Thanks.