Skip to content

Instantly share code, notes, and snippets.

@Log1x
Last active October 31, 2023 00:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Log1x/d02f35f6f9de5f1a5078a3807c6a36c2 to your computer and use it in GitHub Desktop.
Save Log1x/d02f35f6f9de5f1a5078a3807c6a36c2 to your computer and use it in GitHub Desktop.
The Events Calendar (Sage 10)
# events/default-template.blade.php
@extends('layouts.app')
@section('content')
{!! tribe(
\Tribe\Events\Views\V2\Template_Bootstrap::class
)->get_view_html() !!}
@endsection
<?php
use Illuminate\Support\Str;
use function Roots\view;
add_filter('tribe_template_file', function ($file) {
$path = str_replace('/', '.', Str::after(basename($file, '.php'), 'v2/'));
return view()->exists("events.{$path}") ?
view("events.{$path}")->makeLoader() : $file;
});
@joshuafredrickson
Copy link

I made a slight adjustment to filter function, as basename was stripping the path as well as the file extension:

$path = str_replace('/', '.', Str::after(Str::replace('.php', '', $file), 'v2/'));

ℹ️ Note that this will look for add-on views in the base tribe directory. For example: tribe-events/tickets/v2/list/event/cost.php should now be tribe/list/event/cost.blade.php.

@Log1x
Copy link
Author

Log1x commented Oct 30, 2023

Nice. I've never used The Events Calendar before so I didn't know if any of this was still relevent.

Could swap Str::replace() to Str::before($file, '.php') maybe.

@joshuafredrickson
Copy link

I try not to use it if at all possible. :) It's a headache in so many ways.

This snippet gets me most of the way there for a basic install, and for anything else, I reach for supermundano/sage-the-events-calendar, which has its own limitations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment