Virtual Pages for a concert archive?!

I’m new here and haven’t worked with Kirby for too long. I want to create a concert archive. There is already a concert page, now I want to add a new route with a new template. The template then filters which concerts are still to come and only shows past concerts. Can you help me here. I have already looked at the Virtual Pages. But there I can’t find anything about using the content of the original concerts page. Thank you in advance and a Merry Christmas!

Welcome, @Torben_Hammes!

I don’t think you need virtual pages or routes for this - that advanced stuff. This should be able to be solved with less complicated stuff:

I would think:

  • Create a new concerts templates (e.g. maybe that’s the parent of all concert templates). Or if you want it separately from an existing overview page, maybe a concerts.archive template?
  • In that template, you can get a collection of all pages with a concert template and then filter that collection by something like “need to be in the past”

Is that conceptually what you want?

Hey @Torben_Hammes. Welcome to the forum :wave:.

I just noticed you posted the same question on Discord and here. Please try to avoid such cross-postings. It might lead people to answer questions that have long been answered.

This forum here is the primary place to ask support questions. If you want to ask on Discord as well, then please link to the forum post (or vice versa). Thank you :slightly_smiling_face:

1 Like

thank you for this. I’ve seen the forum after I’ve posted on Discord. That’s why it is like it is :wink: Have a great christmas time! :smiley:

No worries! Enjoy the holidays :christmas_tree:

1 Like

Do I understand it correctly that I can then access the same TXT data? The content should only be added once. The concert page is already added and running. Here is already filtered out, which concerts have already taken place. Now I just need the second page, which does not need to be edited. Maybe there is an article in the Docs, but I didn’t knew what to look for.

Thank you :slight_smile:

You can access all content from anywhere.

For example, if you have a page called blog and you want to reference it on the projects page, you can use the page() helper.

Simple example:

<?php if ( $p = page('blog') ) : ?>
<?php echo $p->title() ?>
<?php endif; ?>

For your example, if you have a /concerts folder that contains your concert events as subpages, and now you create a /concerts-archive folder, you would just fetch the children of the concerts page in this page’s template/controller.

<?php if ( $p = page('concerts') ) : ?>
<?php $pastConcerts = $p->children()->filterBy('date', '<', time()); ?>
<?php endif; ?>

You could also create a concerts collection, then filter this collection by future date for the concerts page and past date for the archive.

1 Like

ohh great, that’s what I needed :partying_face: thanks a lot
have a great evening :smiley:

If the structure and layout of both the future and past events is the same, you might want to use the same template, though, instead of repeating the same stuff in two templates.

You could then nevertheless filter the data to display in either page depending on parent page id.

There’s always different ways to go about something like this, it all depends on your use case.