This is what i’m using now for the event calendar:
Essentially removing everything thats included by the event calendar and rendering it again with blade. A huge waste of resources. If anyone has another solution, let me know!
The first filter alone allows for overwrites to be placed in /resources/views/tribe-events/, but doesn’t enable blade.
Thanks! This did the trick and it was the shortest path from A to B.
Only problem was Tribe’s js template, ‘/src/views/month/tooltip.php’. In case anyone else runs into this issue (tooltip markup not generated in month view), the tooltip markup can be easily recreated client-side:
I had a bit of trouble with this, as the events calendar was doing something funky with the standard wp_query data. I found that the following worked as expected:
Actually, still had problems with my previous template. I’ve found that the following snippet works as it will fire all of the hooks defined in the Tribe__Events__Templates::setup_ecp_template() function and handle all the “ninja magic” mentioned there.
Not sure if anyone else has had this problem, but it looks like it’s working as expected for me now.
Needs refactoring, especially to make the default blade filters and Controllers work again, but it was a quick solve to use our custom template for a single event.
I’ve been having a tinker to see how close I could get to solving this (similarly to sage-woocommerce).
Using this, I’ve managed to output some templates with Controller support:
<?php
declare(strict_types=1);
namespace App\Plugins;
use function App\template;
class EventsCalendar
{
public function run(): void
{
$this->addFilters();
}
public function addFilters(): void
{
add_filter('tribe_get_current_template', [self::class, 'setupTemplates'], PHP_INT_MAX);
add_filter('tribe_get_template_part_path', [self::class, 'setupTemplates'], PHP_INT_MAX);
}
public static function setupTemplates(string $original_template): string
{
$template = basename($original_template);
$view = basename(dirname($original_template));
$view_template = "{$view}/{$template}";
$data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {
return apply_filters("sage/template/{$class}/data", $data, $template);
}, []);
$location_paths = [
"tribe-events/{$view_template}",
"tribe-events/{$template}",
$template,
];
$template = \App\locate_template($location_paths);
if ($template) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo template($template, $data);
return get_stylesheet_directory() . '/index.php';
}
return $original_template;
}
}
The only problem is that there are a fair few template parts in Events Calendar that when trying to load will give the error “Fatal error: Allowed memory size of xxxxx”.
Unfortunately, I haven’t really figured that bit out…
But I hope this may help someone get closer to complete support with Blade+Controllers!
Edit:
One of the issues I had was using a custom events template.
Using a custom event template (chosen in Events Calendar settings) would provide strange results (e.g. get_the_ID() returns 0).
Using the default template and overriding in the theme provides more consistent results.
Anyone had success using tribe events templates in Sage 10? Have an upcoming project we’d like to use TEC with it, but having some trouble leveraging a template in Sage 10 as the default TEC events template.
Not exactly, but for what we need and since we heavily customize the templates anyway, just including something this on whatever events template you set (I usually set the default option the way @MWDelaney mentioned) works for our need:
I’m curious if you’ve used this on Sage 10 or recently with The Events Calendar. I’m having issues getting blade to work with it. I’ve tried adding Tribe__Settings_Manager::set_option( ‘tribeEventsTemplate’, ‘views/template-events.blade.php’ ); to app/theme/filters.php. I’ve tried adding the default template, but it didn’t work. I would greatly appreciate your help if you have any insight. Thank you.
This worked for me but here is a hint… Make sure you clear the _transient_tribe_cache… entries in the database because the changes you make in the templates in [theme]/resources/ will not show when developing locally. I spent several hours figuring this out so I hope it helps someone else…
And this replicated the same content seen on the default-template.php override in the V2 edition of the plugin. It has all functionality includeing the nice styling, datepickers etc.
Is this working on Sage 10? I dropped this in and can select the template within TEC settings, but cant include any partials from here. Is there something else that I’m missing? Seems that a lot of the stuff talked about in the above comments pertain to sage 9.
I don’t think this will work for sage 10. There’s a lot changed in sage 10 and the events calendar as well. The code I posted is made for the ‘old’ (the not /v2/ templates) the event calendar templates.
The new the events calendar template logic has more useful hooks I assume, but I haven’t takem an a look at it.
I’m running into an issue getting TEC to run in my Sage 10 environment. Currently trying to get things working using the supermundano/sage-the-events-calendar package. However, I’m stuck on the wp acorn vendor:publish --tag="TheEventsCalendar Templates" step. When I run it, I get the following error in my console:
In VendorPublishCommand.php line 277:
Call to undefined function Illuminate\Foundation\Console\base_path()
Just curious if you or others have encountered this error. Not sure where I’m going wrong.
EDIT: Is it possible the supermundano/sage-the-events-calendar package is intended to be used within the Roots Bedrock environment? I’m not using Bedrock; not sure if that’s related to this issue or not.