Multisite Templates Location

Home Forums Calendar Products Events Calendar PRO Multisite Templates Location

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1006807
    Dan Feeley
    Participant

    We want to start looking into Multisite, we will be using a child theme for each site. My question is, what are my choices for template override files?

    • If i put them in the main theme directory and the theme gets updated the directory gets deleted.
    • if I overwrite the core plugin files and the plugin gets updated I lose all the changes
    • If I copy them to each child site then every time I make a change I need to update each child site

    Is there any other way to store these files but will allow me a central place to maintain them?

    Thank You.

    #1007082
    Barry
    Member

    Hi Dan,

    With a small customization or two it’s possible to store your templates almost anywhere – whether that’s a custom directory, a custom plugin directory or something else.

    The tribe_events_template_TEMPLATE (for specific template files) and tribe_events_template (more generic) hooks provide an opportunity to change the filepath of each template that is loaded by The Events Calendar and its associated plugins, so you can remap everything to whatever location you prefer.

    Example:

    function remap_event_templates( $filepath ) {
    	return str_replace( '/expected/basepath/', '/path/to/new/home/', $filepath );
    }
    
    add_filter( 'tribe_events_template', 'remap_event_templates' );

    This is a pretty simple example and you could tweak as required if you have a more complicated use case or need to make exceptions, etc.

    #1009116
    Dan Feeley
    Participant

    Barry,

    Thanks for the snippet. I’m having a bit of a problem getting it to work. Just to make sure I have it correct, is the “/expected/basepath/” listed above the path to where the modified templates are normally (e.g. ../themes/my-theme/tribe-events/)?

    #1009293
    Barry
    Member

    Hi Dan,

    So “/expected/basepath/” will be whatever The Events Calendar has decided is the location of the template it wants to load.

    In a simple case where you have no template overrides then that will be the path to the plugin’s own views directory. In a more complicated case where you have some template overrides (but not everything is overridden) it will alternately point to either the plugin’s views directory or the tribe-events subdirectory within your theme.

    Does that help?

    #1010813
    Dan Feeley
    Participant

    Thanks Barry,

    That’s what I had assumed (and was trying to do). I must just have a formatting error.
    I don’t want to hold this ticket up but I’ll need to revisit this later when time allows.

    Thanks for the help, if I have any other questions I will open up another ticket.

    #1010968
    Barry
    Member

    Great 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Multisite Templates Location’ is closed to new replies.