Grav Events Plugin

I’m working on an events plugin that takes event frontmatter and processes it for template use. The functionality reminds me a lot of taxonomy functionality but I’m not sure If I should be extending taxonomy in a plugin or going the route of an events management piece in a plugin.

I’ve started work on it here but I’m running into a problem.

I’d like to use event.findEvents({}) in the template system but I’m not sure how to expose that. Any help would be appreciated (or just a little guidance in the right direction.)

The easiest way to add functionality to Twig and in turn, to template files, is to use a PHP object.

If you had an class/object called Events and it had a method called findEvents(), then if you assigned that object to a Twig variable called events, you would be able to do exactly what your are trying to do:

{{ events.findEvents('some event') }}

This is exactly what the breadcrumbs plugin is doing:

and here:

https://github.com/getgrav/grav-plugin-breadcrumbs/blob/develop/templates/breadcrumbs.html.twig#L1

Thanks for the tremendous help! I was able to get a function version of this plugin working today. I’m successfully using it on a dev site at the moment to sort through different events.

Nice work, I have plan to create a events plugin :slight_smile:

Do you have plans on releasing this plugin? I can see it being useful for other people.

I do. I still need to add some functionality to it and clean it up.

Are you doing a calendar with this?

I waiting admin plugin before start develop event plugin, btw you can waiting Kaleb reply :slight_smile:

There have a been a couple of additions to Grav that I think help an events plugin immensely. I’m writing them here for anyone who might run into the same sort of needs.

  1. Date ranges on collections which I think gets released with 0.9.13. This will help create a plugin that extends core Grav functionality instead of creating my own.
content:
    items: @self.children
    order:
        by: date
        dir: desc
    limit: 5
    pagination: true
    dateRange:
        start: 1/1/2014
//        end: 1/1/2015
  1. Extending taxonomy via a plugin

I’m not entirely sure how I would use this but I think it’s wise to search collections by just extending taxonomy somehow instead of creating new search functionality in a plugin. I imagine I’ll extend “event” frontmatter somehow and expose that to taxonomy.

The event plugin concept works fine for me, but I am stuck making the archive of past events. Any ideas?

I’m a bit new to grav in general, so apologies if this is an obvious one. For reoccurring events there is always an extra variable at the end. That means all the instances from a listing go to a 404.

I presume I need a route set up, but I can’t find any info on what exactly needs to be done here.

Any help would be greatly appreciated.