Hi! New to Kirby and very grateful for these forums, which have been a huge help on my first project. I’m stuck on a feature for this project, and would love some advice.
I have a directory structure that looks something like this:
So far, so good. I can browse to media/series-name/episode-01-name/, or to any level up the tree from there, and the appropriate template renders.
What I’d like to do is create a path at podcasts/series-name/archive/, which dynamically shows a paginated archive of all episodes contained within a given series. But I’m not sure how to create pages that don’t exist in the filesystem.
I did find the documentation on virtual content, and on routing; is that the best approach here? How would that work with pagination?
Thank you so much, @JanStieler. This is a huge help.
Unfortunately, it’s not quite working for me: whenever I link to media/slug/episodes/, I’m always routed to the error template. Here’s my routes definition:
My immediate thought is the forward slashes after the episodes in the pattern, but that might not be it. I don’t actually do a lot of pagination on virtual pages myself.
Oh, actually, I can’t tell if you’ve defined $series pages object outside of this. If you haven’t it might help to define it here for clarity while debugging? You have the DOESN’T equals already, but just define it first, and then the != line will be simpler and the $ will exist for the page factory below?
I love making my logic really lean, and not verbose and multi lined, but it can lock me up.
Somebody else might have an actual proper solution to this, but this is the only thing I can detect without creating it locally and not knowing your other files.
Also, your files setup block doesn’t show a typical Listed or Unlisted state of those Series or Episodes (in the episode.yml blueprint you can define the num: at the top of the file and use dates, for example…). But I assumed you were simplifying. If they’re Listed, then ignore this, since you prevent unlisted v pages from returning in your logic.
Wait, you currently prevent listed pages from returning. Just make sure that’s what you want. I usually gate evertyhing to only show listed pages in my logic.
I’m no pro, and I’d like to see where this goes, and I also hope it isn’t misleading.
Thanks so much, @luxuryluke! I really appreciate the reply, and the help. (Answers inline below.)
My immediate thought is the forward slashes after the episodes in the pattern, but that might not be it. I don’t actually do a lot of pagination on virtual pages myself.
Ha, same team: that was one of the first things I tried to debug. I get the error page whether or not the trailing /? follows /episodes.
But I assumed you were simplifying. If they’re Listed, then ignore this, since you prevent unlisted v pages from returning in your logic.
Good catch, and yep—I was simplifying! Sorry for the confusion.
Wait, you currently prevent listed pages from returning. Just make sure that’s what you want. I usually gate evertyhing to only show listed pages in my logic.
Oh that’s probably my misunderstanding: I thought 'listed' => false would apply to the factory-generated page, not the collection I’m building in the template. Just removed it. (And sadly, still getting the error page.)