change template

Home Forums Calendar Products Events Calendar PRO change template

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1485951
    martin75
    Participant

    if this code work to load a custom template when on events/month

    add_filter('gettext', 'tribe_custom_theme_text', 20, 3);
    
    function tribe_theme_template_chooser ( $template ) {
    
    	if ( ! tribe_is_event() ) return $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_event1.php' );
    	}
    	if ( tribe_is_month() ) {
    		$template = locate_template( 'tpl-full-width-with-google-ads.php' );
    	}
    	
    	return $template;
    	
    	
    }

    then why wont this code work to do the same for maps view ??

    	if ( tribe_is_map() ) {
    		$template = locate_template( 'tpl-full-width-with-google-ads.php' );
    	}
    	
    	return $template;
    #1487199
    Cliff
    Member

    Hi again, Martin.

    If I’m not mistaken, Map View actually always loads via Ajax.

    Try this instead:

     $is_map_view = (
    tribe_is_map()
    || Tribe__Events__Pro__Main::instance()->is_pro_ajax_view_request( false, 'map' )
    );

    Please let me know how this goes for you.

    #1487362
    martin75
    Participant

    many thanks Cliffe i tried this , with no success

    function tribe_theme_template_chooser ( $template ) {
     
        if ( ! tribe_is_event() ) return $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_event1.php' );
        }
        if ( tribe_is_month() ) {
            $template = locate_template( 'tpl-full-width-with-google-ads.php' );
        }
         
        return $template;
    $is_map_view = (
    tribe_is_map()
    || Tribe__Events__Pro__Main::instance()->is_pro_ajax_view_request( false, 'map' )
    );
         
         
    }
    
    if ( tribe_is_map() ) {
        $template = locate_template( 'tpl-full-width-with-google-ads.php' );
    }
     
    return $template;
    
    add_filter( 'template_include', 'tribe_theme_template_chooser', 11 );

    the code is in my themes functions.php

    thanks again Cliffe

    #1487415
    Cliff
    Member

    You’d need to replace tribe_is_map() with $is_map_view

    #1487422
    Cliff
    Member

    Another thing to think about is that the template_include filter might not be the right one to use if loading via Ajax

    #1487920
    martin75
    Participant

    i have accepted defeat gracefully ! I have now change default template to the above template and all works fine i have changed the organizer and venue template call no problem and the single event .
    for organiser and venue i have used

    <?php
    if ( is_single() && tribe_is_event_organizer() ) {
        get_template_part( 'organizer_template' );
        return;
    }
    if ( is_single() && tribe_is_event_venue() ) {
        get_template_part( 'venue_template' );
        return;
    }

    both work fine.
    for single page i used
    `// Single event page
    if ( is_single() ) {
    $template = locate_template( ‘single_event1.php’ );
    }
    now the big question what would i use to call a different template for the tribe-ext-instructor-linked-post-type ?thought a good place to ask as you made that linked post type masterpiece!

    #1488892
    Cliff
    Member

    Thanks for the thorough reply and kind words.

    https://theeventscalendar.com/extensions/linked-post-type-instructors/ has its own template file, and that extension is meant to be forked (i.e. a template).

    #1509421
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘change template’ is closed to new replies.