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:
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.
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.
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.
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.
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.