Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #731581

    Hi,

    I’m using the Modern Tribe Events Calendar plugin with Enfold.

    I have a section of my site on which I’m using a sub-menu (https://brightgreenlearning.com/academy). I would like to have that same sub-menu display on the calendar homepage (https://brightgreenlearning.com/courses) and also on individual events (e.g. https://brightgreenlearning.com/course/fundamentals-of-collaboration-by-design-core-module ).

    Is there any way to do this given that I’m not using (and believe I cannot use) the Advanced Layout Editor on those pages and custom posts?

    If I can’t display the sub-menu as a sticky menu below the main navigation then perhaps I could show it in a Sidebar on those pages?

    Thanks in advance,
    Eoghan
    (thatcommsguy)

    #733447

    Hey thatcommsguy,

    Thank you for using Enfold.

    Please edit the templates inside the config-events-calendar > views folder. Add the do_shortcode function in combination with the full width sub menu shortcode.

    // https://developer.wordpress.org/reference/functions/do_shortcode/

    Example:

    echo do_shortcode("[av_submenu which_menu='center' menu='' position='center' color='main_color' sticky='true' mobile='disabled' mobile_submenu=''][av_submenu_item title='Menu Item 1'][av_submenu_item title='Menu Item 2']
    [/av_submenu]");
    

    Best regards,
    Ismael

    #733585

    Thanks Ismael.

    I understand that I need to edit the templates (and will add them within my child theme to avoid them beîng overwritten when there are updates). But I’m not sure where in the templates I should be added the do_shortcode snippet. I’ve tried adding it in a couple of different places in the single-event.php template but without any effect.

    Any further guidance you can offer would be most welcome.

    Eoghan
    (thatcommsguy)

    #733851

    Hi!

    In the single-event.php file, you can add it below this container.

    <div id="tribe-events-content" class="tribe-events-single vevent hentry">
    
    	<p class="tribe-events-back"><a href="<?php echo tribe_get_events_link() ?>"> <?php _e( '&laquo; All Events', 'avia_framework' ) ?></a></p>

    And look for this line in the default-template.php file.

    <div id="tribe-events-pg-template">
    

    Add the shortcode below and don’t forget to wrap it inside a php tag.

    Best regards,
    Ismael

    #734663

    Hi Ismael,

    Sorry if I’m coming across as incompetent here. I’m just not managing to get this to work. (Perhaps I should be getting support from Modern Tribe in this case?)

    Can you confirm the following (at least for single event listings):
    1. I need to edit the file single-event.php and copy it to /wp-content/themes/enfold-child/tribe-events, which will cause the plugin to use that file rather than the default
    2. I only need to add the shortcode snippet below to that page,

    echo do_shortcode("[av_submenu which_menu='center' menu='' position='center' color='main_color' sticky='true' mobile='disabled' mobile_submenu=''][av_submenu_item title='Menu Item 1'][av_submenu_item title='Menu Item 2']
    [/av_submenu]");

    …underneath the following container:

    <div id="tribe-events-content" class="tribe-events-single vevent hentry">
    
    	<p class="tribe-events-back"><a href="<?php echo tribe_get_events_link() ?>"> <?php _e( '&laquo; All Events', 'avia_framework' ) ?></a></p>

    …and wrapped in php tags as follows

    <?php [snippet] ?>

    3. Do I need to add anything to the original snippet you provided (e.g. the name of the sub-menu, any additional menu items that I’ve since added, etc…?

    4. Do I need to add any other code to the single-event.php file or to any other file to make this work?

    I’ve tried changing the single-event.php file in other ways and uploading it, just to see whether that is indeed the file that’s being used for a page like this: https://brightgreenlearning.com/course/fundamentals-of-collaboration-by-design-core-module
    But I haven’t succeeded.

    Again, sorry for not managing to follow your instructions properly. The Enfold support is really great and I generally can get everything to work first time…I’ve just hit a wall on this one.

    Thanks,
    Eoghan

    #735988

    I was faced with this same problem and have figured it out after piecing 2 solutions together from different threads.

    1. First add the following to the functions.php in the child theme, this is to get it to use the files within the child theme instead of the main theme.

    
    
    add_action('tribe_events_template', 'avia_events_template_paths_mod', 10, 2);
    function avia_events_template_paths_mod($file, $template)
    {
        $redirect = array('default-template.php', 'single-event.php');
        if(in_array($template, $redirect))
        {
            $file = get_stylesheet_directory() . "/config-events-calendar/views/".$template;
        }
    
        return $file;
    }
    
    

    2. I added the subnav shortcode into the default-template.php only as also adding it to the single-event.php produced 2 subnavs on the single event page.

    Add it above this line: <div class=’container_wrap container_wrap_first main_color fullsize’> which it should look like below

    
    
    echo do_shortcode("[av_submenu which_menu='center' menu='' position='center' color='main_color' sticky='true' mobile='disabled' mobile_submenu=''][av_submenu_item title='Menu Item 1'][av_submenu_item title='Menu Item 2']
    [/av_submenu]");
    
    <div class='container_wrap container_wrap_first main_color fullsize'>
    
    

    Hope this helps.

    #735993

    Hi!


    @crawford13
    Thank you for sharing your solution! Very kind of you :)


    @thatcommsguy
    Please refer to @crawford13’s post above :)

    Cheers!
    Yigit

    #736128

    Thank you so much @crawford13. It is indeed very kind of you to jump in here.

    Sadly I’ve still not managed to get it working, despite having followed (or tried to follow) your steps.

    One possible clue to where this is going wrong is that my default-template.php file doesn’t seem to be the same as yours. Here’s the complete contents of my file (before adding any shortcode):

    <?php
    /**
     * Default Events Template
     * This file is the basic wrapper template for all the views if 'Default Events Template'
     * is selected in Events -> Settings -> Template -> Events Template.
     *
     * Override this template in your own theme by creating a file at [your-theme]/tribe-events/default-template.php
     *
     * @package TribeEventsCalendar
     *
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    get_header();
    ?>
    <div id="tribe-events-pg-template">
    	<?php tribe_events_before_html(); ?>
    	<?php tribe_get_view(); ?>
    	<?php tribe_events_after_html(); ?>
    </div> <!-- #tribe-events-pg-template -->
    <?php
    get_footer();
    

    Any idea why this is different? Is it because I’m not on their PRO version? (I have Tickets Plus, but the free calendar.)

    And any idea where I might try inserting the do_shortcode here?

    It’s also still unclear to me whether or not I should be wrapping the shortcode in php tags when I do insert it. Your example above doesn’t wrap it (from what I can see).

    Thanks. I’m really keen to get this solved.

    Eoghan

    @thatcommsguy

    #736130

    @thatcommsguy, it looks like you are using the default.template.php from The Events Calendar plugin folder instead of from the Enfold theme folder >config-events-calendar. Make sure you copy the folder structure the same to the enfold-child theme folder, which should be:

    enfold-child
    -config-events-calendar
    –views
    —default-template.php

    Yes you need to wrap the shortcode in <?php [INSERT SHORTCODE] ?>. Sorry I forgot that in the code I provided. It should be as follows.

    
    <?php 
    echo do_shortcode("[av_submenu which_menu='center' menu='' position='center' color='main_color' sticky='true' mobile='disabled' mobile_submenu=''][av_submenu_item title='Menu Item 1'][av_submenu_item title='Menu Item 2']
    [/av_submenu]");
    ?>
    
    <div class='container_wrap container_wrap_first main_color fullsize'>
    

    Also be sure to add the code I provided into the functions.php in the enfold-child folder.

    #736333

    Continued thanks @crawford13. I had not realized that I should be using templates provided by Enfold. (I forgot that Enfold is specifically configured to be compatible with these plugins.)

    So, I now have a functions.php in my child theme that includes (among other snippets that are all working properly) the following:

    
    /* Telling the Event Calendar plugin to use the view templates found in the Child Theme
    */
    
    add_action('tribe_events_template', 'avia_events_template_paths_mod', 10, 2);
    function avia_events_template_paths_mod($file, $template)
    {
        $redirect = array('default-template.php', 'single-event.php');
        if(in_array($template, $redirect))
        {
            $file = get_stylesheet_directory() . "/config-events-calendar/views/".$template;
        }
    
        return $file;
    }
    

    And I have the default-template.php file sitting in /wp-content/themes/enfold-child/config-events-calendar/views and looking like this:

    
    <?php
    
    global $avia_config;
    
    	/*
    	 * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
    	 */
    	 get_header();
    		
    	 $title = tribe_is_month() ? __('Calendar of Events', 'avia_framework') : tribe_get_events_title(false);
     	 $args = array('title'=> $title, 'link'=>'');
    
     	 if( !is_singular() || get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title($args);
     	 
     	 do_action( 'ava_after_main_title' );
     	 
    	 ?>
    	 
    <?php 
    echo do_shortcode("[av_submenu which_menu='center' menu='' position='center' color='main_color' sticky='true' mobile='disabled' mobile_submenu=''][av_submenu_item title='Menu Item 1'][av_submenu_item title='Menu Item 2']
    [/av_submenu]");
    ?>
    
    		<div class='container_wrap container_wrap_first main_color fullsize'>
    
    			<div class='container'>
    
    				<main class='template-page template-event-page content av-content-full units' <?php avia_markup_helper(array('context' => 'content','post_type'=>'page'));?>>
    					
    					 <div id="tribe-events-pg-template">
                       
                     	<?php
                     	
    					tribe_events_before_html();
    					tribe_get_view();
    					tribe_events_after_html(); 
    					
    					?>
    					
    					</div> <!-- #tribe-events-pg-template -->
    					
    				<!--end content-->
    				</main>
    
    			</div><!--end container-->
    
    		</div><!-- close default .container_wrap element -->
    
    <?php get_footer(); ?>
    

    But still the sub-menu in question appears on neither of the following pages:
    https://brightgreenlearning.com/courses

    This is the sub-menu I’m trying to have appear on those pages:

    Perhaps you could take one final look at the above and see if you can spot what I’m doing wrong or what’s going wrong.

    Thank you so much,
    Eoghan
    (@thatcommsguy)

    #736511

    @thatcommsguy Would you be willing to give me temporary access to your site? If so please send login info to (Email address hidden if logged out) . I think I know what the problem is and it will be easier and faster if you allow me access. Up to you though.

    #736521

    Sure! I’m a trusting kind of guy!

    The details are on their way.

    Thanks,
    Eoghan

    #736530

    Ok, since I cannot get to the default-template.php from the editor, please replace it with the code below and you should be all set:

    
    <?php
    
    global $avia_config;
    
    	/*
    	 * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
    	 */
    	 get_header();
    		
    	 $title = tribe_is_month() ? __('Calendar of Events', 'avia_framework') : tribe_get_events_title(false);
     	 $args = array('title'=> $title, 'link'=>'');
    
     	 if( !is_singular() || get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title($args);
     	 
     	 do_action( 'ava_after_main_title' );
     	 
    	 ?>
    <!-- Add subnav -->
    <?php 
    echo do_shortcode("[av_submenu which_menu='' menu='96' position='center' color='main_color' sticky='aviaTBsticky' mobile='disabled']
    [av_submenu_item title='Menu Item 1' link='' linktarget='no' button_style='']
    [av_submenu_item title='Menu Item 2' link='' linktarget='no' button_style='']
    [/av_submenu]");
    ?>
    
    		<div class='container_wrap container_wrap_first main_color fullsize'>
    
    			<div class='container'>
    
    				<main class='template-page template-event-page content av-content-full units' <?php avia_markup_helper(array('context' => 'content','post_type'=>'page'));?>>
    					
    					 <div id="tribe-events-pg-template">
    
               
                     	<?php
                     	
    					tribe_events_before_html();
    					tribe_get_view();
    					tribe_events_after_html(); 
    					
    					?>
    					
    					</div> <!-- #tribe-events-pg-template -->
    					
    				<!--end content-->
    				</main>
    
    			</div><!--end container-->
    
    		</div><!-- close default .container_wrap element -->
    
    <?php get_footer(); ?>
    

    I also turned on the Avia Layout Builder debug mode, which you can turn off by removing the code from the functions.php if you do not need to have it on for anything.

    #736655

    With huge thanks to @crawford13, plus a little extra investigating on my part this evening, I finally got this working.

    To help others, if you want to add a sub-menu on event calendar pages, you need to do the following:

    1. Add this code to your functions.php

    
    add_action('after_setup_theme', function() {
        if(is_child_theme()) remove_action('tribe_events_template', 'avia_events_tempalte_paths', 10, 2);
    });
    
    add_action('tribe_events_template', 'avia_events_template_paths_mod', 10, 2);
    function avia_events_template_paths_mod($file, $template)
    {
        $redirect = array('default-template.php', 'single-event.php');
        if(in_array($template, $redirect))
        {
            $file = get_stylesheet_directory() . "/config-events-calendar/views/".$template;
        }
    
        return $file;
    }
    

    Note that even though I’m only modifying the default-template.php file below, I still included single-event.php in the redirect array here:
    $redirect = array('default-template.php', 'single-event.php');

    2. In /wp-content/themes/enfold/config-events-calendar/views find default-template.php and create a local copy.

    Edit it as follows, adding the do_shortcode for the submenu, wrapped in php tags, just above <div class=’container_wrap container_wrap_first main_color fullsize’>

    
    <!-- Add subnav -->
    <?php 
    echo do_shortcode("[av_submenu which_menu='' menu='96' position='center' color='main_color' sticky='aviaTBsticky' mobile='disabled']
    [av_submenu_item title='Menu Item 1' link='' linktarget='no' button_style='']
    [av_submenu_item title='Menu Item 2' link='' linktarget='no' button_style='']
    [/av_submenu]");
    ?>
    
    		<div class='container_wrap container_wrap_first main_color fullsize'>
    

    That’s what worked for me.

    Thanks again to @Ismael, @Yigit and – in particular – @crawford13

    #736656

    @thatcommsguy Happy to hear you got it all working after our last conversation. Glad I could provide a little bit of help.

    #738023

    Hi,

    Thanks for sharing this solution :)

    Best regards,
    Nikko

Viewing 16 posts - 1 through 16 (of 16 total)
  • The topic ‘Add sub-menu to Event Calendar posts and pages’ is closed to new replies.