How do we override default Templates in Events+?

We have a custom page (page-events.php) which we have <?php echo do_shortcode('[eab_archive]'); ?> amongst our layout.

I presume, depending on settings, this uses the /plugins/events-and-bookings/default-templates/shortcode-archive-default.php to output the shortcode. What we'd like, is to override the code surrounding the output. Is there a way to do this, EG: including the shortcode-archive-default.php in our theme, and editing that, or would we have to do our own wp_query using the post type eab_events and go from there?

  • Sajid
    • DEV MAN’s Sidekick

    Hi @betterstudio,

    Hope you are doing good today :slight_smile:

    There are number of ways to override the template in Events + plugin. The most standard one is creating a page template archive-incsub_event.php in your theme or child theme.

    You can also use the existing template as a base and can rename it like above.

    Hope that helps, let me know if you need further assistance.

    Cheers, Sajid

    • betterstudio
      • Flash Drive

      Thanks Sajid. We have successfully been able to use archive-incsub_event.php or override the archive itself. In this we use the shortcode eab_archive to output the event items themselves. Obviously this uses the shortcode template from the plugin dir (EG: shortcode-archive-default.php) to output this shortcode. What we would like to do ideally is override this default shortcode template too. Do we have any options for that?

      Thanks,
      Adam

  • Sajid
    • DEV MAN’s Sidekick

    Hi @betterstudio,

    Hope you are doing good today :slight_smile:

    Oh I am sorry for confusion, for shortcode template follow the below steps.

    1. Go to following location and download the "shortcode-archive-default.php" file.
    wp-content/plugins/events-and-bookings/default-templates

    2. Rename this file (e.g. shortcode-events.php) and upload to your current theme.

    3. Now use eab_archive shortcode and specify the name of custom template in template parameter like below. No need to include the extension here ".php".
    [eab_archive template="shortcode-events"]

    Take care and have a nice day :slight_smile:

    Kind Regards,
    Sajid J

  • Sajid
    • DEV MAN’s Sidekick

    Hi @betterstudio,

    Hope you are doing good today :slight_smile:

    Oh I am sorry for confusion, for shortcode template follow the below steps.

    1. Go to following location and download the "shortcode-archive-default.php" file.
    wp-content/plugins/events-and-bookings/default-templates

    2. Rename this file (e.g. shortcode-events.php), upload to your current theme and create your own template base on it.

    3. Now use eab_archive shortcode and specify the name of custom template in template parameter like below. No need to include the extension here ".php".
    [eab_archive template="shortcode-events"]

    Take care and have a nice day :slight_smile:

    Kind Regards,
    Sajid J

  • Sajid
    • DEV MAN’s Sidekick

    Hi Marcelo Berwanger,
    Hope you are doing good today :slight_smile:

    That is not the patch or hotfix. Its the way of customizing the existing page templates according to your requirements. Events+ plugin gives this ability to load/overide custom templates instead of using the default one. The above is just the explanation of how template override works.

    Also, the changes are in your active child theme and safe. These changes/templates will not be lost when you will update the plugin.

    Take care and have a nice day :slight_smile:

    Best Regards,
    Sajid

  • Marcelo Berwanger
    • The Crimson Coder

    Hi @sjaved!
    I'm good and I Hope you are doing good today too!

    Your answer makes me tranquil.

    One more question. How I override or extend the function 'get_archive_content'. I want to use the standard source code without modifying the plugin core. For example:

    I call the shortcode:
    [eab_archive template="shortcode-archive-frontpage" category="eventos-destaque" limit=3 order="DESC"]

    The shortchode-archive-frontpage.php have:

    <div class="eab-event-body">
    			<?php echo eab_call_template('get_archive_content_frontpage', $event);  ?>
    </div>

    It's possible? How?

    Regards,
    Marcelo B

  • Sajid
    • DEV MAN’s Sidekick

    Hi Marcelo Berwanger,
    Hope you are doing good today :slight_smile:

    That is basically call a templating class and its method. But as mentioned above you can override the files without worrying about updates and modifying the core files by following steps below.

    1. Go to events-and-bookings/lib/ copy the class_eab_template.php file.

    2. Move this class into your child theme.

    3. Open it up and replace the name of class with your own custom class name like (very important).

    Change this:
    Eab_Template

    Into this:
    Custom_Eab_Template

    4. Include this file in your functions.php file.

    5. Make changes in directly in get_archive_content method/function in side your own class instead of extending it.

    6. Done!

    Tip: This class has all the template functions so you can override any template directly.

    Hope that helps! If you need further assistance, then please start your own thread :slight_smile:

    Best Regards,
    Sajid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.