Show only upcoming events

I’ve read the tutorials and checked the files but I’m stuck and hope someone could help: I want to create a blog with events in the future and in the past. This works quite nice. Now I want the following: On the homepage I only want to display all upcoming events, so date >= today. All expired events should still be available somewhere (separate category or else). I’ve checked the collections and found some ordering information but I did not find a filter option. The blog should show only upcoming events, the closest one (e.g. today or tomorrow) at the top so that you could scroll down to february, march etc.
What would be the best way to do this? I guess it would be possible by a) removing all old events into a separate folder, and b) change the sort order to date ascending.
Would this be the preferred way? Many thanks!

By default collections are filtered so that only items that are considered published are included. This means that you won’t be able to display a collection of unpublished items. The purpose of the published state is so you can create content but not have them showing up on your site until your ready.

I think you should make use of a custom taxonomy field for controlling your upcoming events. You could also use a custom header to set a date for when the event is active. You could use a custom plugin (or an event in your theme) similar to the Archives plugin that dynamically sets a taxonomy field (ie upcoming) based on the date of the event. This way you can easily create a list with a taxonomy based filter of upcoming events. Also they would drop off the list when they are active, and you could even have another list for past events too.

OK, thanks a lot for this advice, it’s a very good idea to build the taxonomy automatically! As I’m using the blog template I already have the Archives plugin enabled. I’ve added these lines to existing archives.php around line 80:
— PHP
if (!isset($taxonomy[‘date_passed’])) {
if ( time() > $page->date()) {
$taxonomy[‘date_passed’] = ‘true’;
}
else
{
$taxonomy[‘date_passed’] = ‘false’;
}
}

Not sure whether it works. At least it throws no error. But then? I hoped I could use URL 'date_passed:true' right out of the box, similar to e.g. 'archives_month:jul_2014'. But it does not work. I tried to change archives.html.twig to show the list but I also did not get this to work. Will see whether I find a way the next days...

BTW, best not to modify the archives plugin directly. Better to create your own plugin (or do it in the theme .php file).

Hi rhukster, in the end it was much easier as expected :slight_smile: I started working on a fork of the archive plus plugin but then I noticed the option of filtering by date. So I just added a new folder ‘02.upcoming’ into my user/pages folder. I copied the blog.header.jpg and the blog.md. Then I modified blog.md:

  1. Changed content:items into
    items: 
	  @taxonomy.tag: journal
  1. Added date filter:
	dateRange:
      start: today

That’s it! No need to change any plugins or else. Also set the sort order to ascending so the closest date will be displayed at the beginning. Additionally I’ve created a similar view for all outdated events using

	dateRange:
      end: today

Thanks a lot for your support! I really appreciated it!

Awesome! It’s really quite simple yet surprisingly powerful when you get the hang of it.

Update in case someone else reads this and wants to do the same: If you want to display also todays events have to set start to yesterday:

dateRange:
start: yesterday

I am trying to achieve the same thing and started with the events plugin. Hoping that it will work out of the box. Does the discussion above mean that I can do it without events? I am a bit confused here.