Modifying Child Theme Files

Home Forums Calendar Products Events Calendar PRO Modifying Child Theme Files

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1322370

    Hello,

    I am trying to modify the following file as part of a child theme, so that any changes to the core of TEC Pro does not get overwritten during an update:

    plugins/events-calendar-pro/src/Tribe/Templates/Mods/List_View.php

    While following your theming guide, there is no real mention of how to edit those types of files. I have tried the following paths with no success.

    child-theme/tribe-events/pro/src/Tribe/Templates/Mods/List_View.php
    child-theme/tribe-events/pro/Tribe/Templates/Mods/List_View.php
    child-theme/tribe-events/pro/Templates/Mods/List_View.php
    child-theme/tribe-events/pro/Mods/List_View.php
    child-theme/tribe-events/pro/List_View.php

    My overall goal, is to change any links that send you back to the default Events page to become “<< Back” links that only navigates to the previous page that was visited instead. I have finished this modification for both the single-venue.php and the single-organizer.php pages. This file is next on my list as it appears when you access the list of recurring events. I am open to other solutions as well if this is not possible, through the normal theming process.

    Thanks for you help.

    #1322906
    Cliff
    Member

    Hi, Corinne.

    That Mods/List_View.php file is the Tribe__Events__Pro__Templates__Mods__List_View class, the only use of which is Line 157 of /wp-content/plugins/events-calendar-pro/src/Tribe/Main.php

    So if you’re wanting to customize that file, you’d actually want to unhook its usage on that tribe_events_list_before_the_content action hook and then add your own add_action on that hook.

    To confirm, that file isn’t able to be overridden via child theme. Only files in the plugin-name/src/views directory are overridable via our Themer’s Guide. Each file that is overridable also has a comment in the top of the file that specifies that it’s overridable and in what location of your child theme to put it.

    The easiest implementation of this might be via JavaScript, using https://www.w3schools.com/jsref/met_his_back.asp.

    Please let me know how this goes for you.

    #1324712

    For anyone referencing this question in the future, here is the code I added to my theme’s function.php file to overwrite the “<< All Events” link on the page that shows all recurring instances of a single event, and replace it with a link that simply goes back to the last page visited instead.
    The reason for replacing these links was due to the need of putting the default event page in an iframe, so that I could have the calendar with the filter bar on different pages other than just the default events page that is forced by the plugin. Since the filter bar does not work by shortcode at the time of this post.

    My workaround was to create a completely blank template page in my theme, thus there would be no header, footer, wpadminbar, etc. I set the Events Templates to use this new template then put the full calendar into an iframe on the pages of my choosing.

    Plugins used:

    The Events Calendar
    The Events Calendar PRO
    The Events Calendar Filter Bar
    Iframe Resizer: https://github.com/davidjbradshaw/iframe-resizer

    Code added to function.php:

    remove_action( ‘tribe_events_list_before_the_content’, array( ‘Tribe__Events__Pro__Templates__Mods__List_View’, ‘print_all_events_link’ ) );
    add_action( ‘tribe_events_list_before_the_content’, ‘print_all_events_link’ );

    function print_all_events_link(){
    // Only add this link if we are viewing all instances of a recurring event (ie, ‘/event/some-slug/all/’)
    if ( ‘all’ !== $GLOBALS[‘wp_query’]->get( ‘eventDisplay’ ) ) {
    return;
    }

    if ( tribe_is_recurring_event() ) {
    ?>
    <p class=”tribe-events-back tribe-events-loop”>
    ” rel=”bookmark”><?php printf( __( ‘« Back’, ‘tribe-events-calendar-pro’ ), tribe_get_event_label_plural() ); ?>

    <?php
    }
    }

    The other 2 places I changed this back type of functionality was:

    /views/pro/single-venue.php
    /views/pro/single_organizer.php

    #1325598
    Cliff
    Member

    Corinne, thanks for the thorough update and for sharing for others’ benefit.

    Have a great rest of your week!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Modifying Child Theme Files’ is closed to new replies.