supermundano / sage-the-events-calendar

Add The Events Calendar support to Sage 10.
MIT License
12 stars 9 forks source link

override single-event.php #4

Open lgt opened 2 years ago

lgt commented 2 years ago

Hi there!

is there a way to override single-event.php?

cfaria commented 2 years ago

Have you tried copying single-event.php to your-sage10-theme/tribe/events/v2/ ?

deroccha commented 2 years ago

Hi, Yes I done that but will be not mapped.

cfaria commented 2 years ago

My fault, that template is at the same level as v2, so you'll need to place it in your-sage10-theme/tribe/events/

Can you test that?

lgt commented 2 years ago

Hi,

I have been trying but will not work. The only way I can include the template is like including it in the default-template.blade.php

@extends('layouts.app')

@section('content')

  @if(tribe( Template_Bootstrap::class )->is_single_event())
    {{-- Conditionally display something if we are in a single event --}}
    @include('tribe.events.v2.single-event')
  @else

    {!! tribe( Template_Bootstrap::class )->get_view_html(); !!}
  @endif
@endsection

But this has some downsides

joeysmith-hudds commented 1 year ago

Any updates on this @EHLOVader?

Seems like I can only override files in the /v2/ folder

EHLOVader commented 1 year ago

@joeysmith-hudds I'm not sure.

I thought they were switching everything over to v2 but looking back now at their docs it appears they have some exceptions. https://theeventscalendar.com/knowledgebase/customizing-template-files-2/

Perhaps there is a better way to go about it. But this worked for me when I needed to customize templates before.

EHLOVader commented 1 year ago

I'm left even more confused about how overriding single-event is supposed to work.

It doesn't even use the tribe/events path. The instructions in the header docblock of the file say

Override this template in your own theme by creating a file at [your-theme]/tribe-events/single-event.php

So I'm going to try a few things and see if it works.

UPDATE: So I found another hook, tribe_events_template and tribe_events_template_[template file] They use the latter for some block overrides with the single-event.php ( tribe_events_template_single-event.php )

So using these we can hook the template call and replace it with a blade template if it exists. The only question is where should that blade template exist?

If we follow their folder structure it would be resources/views/tribe-events/ but we have the resources/views/tribe/events/ from the v2 templates.

Which is best? I myself vote for the resources/views/tribe/events/ It isn't consistent but is cleaner

It appears from the template exceptions there may be other instances that need tested also. Modules (?) and blocks.