Hi,
I try to get The Events Calendar by Modern Tribe working with Sage 10. But don’t know how to get it functional. Loading the plugin files as blade is not so important to me. I’m looking for a way to include it in the app.layouts, so it’s loading with header and footer. I tried to use:
{{--
Template Name: Events
--}}
@extends('layouts.base')
@section('content')
<div id="tribe-events-pg-template">
<?php tribe_events_before_html(); ?>
<?php tribe_get_view(); ?>
<?php tribe_events_after_html(); ?>
</div> <!-- #tribe-events-pg-template -->
@endsection
But it’s not working for all views. Anybody got an idea?
I took a look at the Woocommerce integration for Sage 10:
For Sage 9 I found:
https://gist.github.com/Xilonz/8f6192dccf9f6349ad40a7b3395c9648
https://discourse.roots.io/t/the-events-calendar-and-sage-9-blade/8667/16?u=huub
<?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;
}
}