• Resolved pauly231

    (@pauly231)


    i have used the plugin for many years and love it , i had some template overides set up and have been putting off going to the v2 views. now i feel its time to get it done.
    i have always used a full width template for the /events month view and a single.php for all other pages with sidebar.

    i used for many years

    function tribe_theme_template_chooser ( $template ) {
    
       
         * Example for changing the template for the single-event page to custom-page-template.php
         * Template is usually set to /plugins/the-events-calendar/src/views/default-template.php
         * You might wish to include some things from that template in your custom one, such as
         * the function tribe_get_view() which helps format the content within your template.
         * You can modify this example to set the template for any tribe page. Month view could be
         * modified by instead using the tribe_is_month() condition.
        
    
        // Single event page
        if ( is_single() ) {
            $template = locate_template( 'single_event2.php' );
        }
        if ( tribe_is_month() ) {
            $template = locate_template( 'tpl-full-width.php' );
        }
                   return $template;
        }
    
    add_filter( 'template_include', 'tribe_theme_template_chooser', 52 );

    with great success . this how ever does no longer work with the v2 views ,

    i have installed the tweaks extensions to try to resolve this.
    i have the display setting as full-width.php and the tweak setting as calendar only ,in my functions i have

    add_filter(
      'tribe_events_views_v2_use_wp_template_hierarchy',
      function($template) {
        if ( ! is_month() ) {
           $template = locate_template( 'single.php' );
        }
         
        return $template;
      },
      10,
      4
    );
    

    this leads to undesirable outcomes . what is the best function to use to simpley use the default events calendar view for all views that are not month? thanks in advance

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Abz

    (@abzlevelup)

    Hi @pauly231,

    We appreciate the kind words, good to know that you are loving our plugins. Thanks for providing me more information about what you are trying to accomplish here, as well.

    You might want to use this filter tribe_get_option_tribeEventsTemplate — this would grab the Page Template in which the view “is based off of” (“default”, “event” or “page”). Let’s say I’m using default theme (2020), then I set the Full Width Template, the value it would return would be templates/template-full-width.php.

    See the dev docs here:
    https://docs.theeventscalendar.com/reference/hooks/tribe_get_option_optionname/

    Another option would be, you could do something like this, to check if the month view and then change the template as V2 relies heavily on context:
    'month' === tribe( 'context' )->get( 'view' )

    Let me know if this helps, and how it goes!

    Best,
    Abz

    Thread Starter pauly231

    (@pauly231)

    thanks for getting back to me , im a little confuse by your answer , in the events cal display settings i have default page template selected. all is fine , the month view is very busy so id like to have JUST the month view full width page , this function will no longer work

    function tribe_theme_template_chooser ( $template ) {
    
        if ( tribe_is_month() ) {
            $template = locate_template( 'tpl-full-width.php' );
        }
                   return $template;
        }
    
    add_filter( 'template_include', 'tribe_theme_template_chooser', 52 );

    it worked for 7-8 years fine but not with the new v2 displays. is there an upto date function i could try ? ive tried so many im ready to give up and return to v1 and never update again!! many thanks in advance

    Plugin Support Abz

    (@abzlevelup)

    Hi @pauly231,

    No worries. Thanks for giving me more context here. Apologies for the confusion as well. Could you provide me a direct URL to your Events Page?

    Moreover, I would definitely check with the team if there are workarounds for this one here. I would get back to you as soon as I hear from them.

    Appreciate your time and patience.

    Best,
    Abz

    Plugin Support Abz

    (@abzlevelup)

    Hi @pauly231,

    One of our devs, came back to me with a workaround and should do the trick. I also tested it out to make sure it is working.

    You could add this to your child theme or install a third-party plugin like Code Snippets.

    add_action(
    	'tribe_template_include_html:events/v2/month/calendar-header', // only triggers on month template loads
    	function( $html ) {
    		$html .= "<style>
    				#primary { min-width: 100%; } /* the main content section */
    				#secondary { display: none; } /* the sidebar content section */
    			</style>";
    		
    		return $html;
    	}
    );

    One thing to note that, depending on the theme you’re using — the CSS selectors (IDs/classes) might be different on your end. Please do update the CSS accordingly.

    Let me know how it goes.

    Best,
    Abz

    Thread Starter pauly231

    (@pauly231)

    beautiful !!

    add_action(
    	'tribe_template_include_html:events/v2/month/calendar-header', // only triggers on month template loads
    	function( $html ) {
    		$html .= "<style>
    				#main { min-width: 100%; } /* the main content section */
    				#sidebar { display: none; } /* the sidebar content section */
    			</style>";
    		
    		return $html;
    	}
    );

    this did the trick for me , thanks so much for your help
    kind regards

    Plugin Support Abz

    (@abzlevelup)

    Hey @pauly231,

    Good to know that it worked on your end. I would definitely let our awesome Dev Stephen know as well.

    No worries! We are here to help. Would also be good if you could review us, here — if you have some time. Thanks for helping spread the word! It’s folks like you who make our work enjoyable, and we appreciate you choosing our plugins for your site.

    I’d be marking this as resolved, and please do not hesitate to bump a new ticket for different topic/issue.

    Have a great day, Paul!

    Best,
    Abz

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘v2 views’ is closed to new replies.