Overriding the generate_markers method

Home Forums Calendar Products Events Calendar PRO Overriding the generate_markers method

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1428521
    sabinevi
    Participant

    After a lot of digging in the code, I succeeded in adding the name of the venue to the tooltip in the Google map showing the venues and their events. I did that by adding the extension ‘Display multiple events with the same venue in Map tooltips’, altering the javascript of the extension and altering the generate_markers() method in the events-calendar-pro/src/Tribe/Geo_Loc.php (added the venue name).
    Of course I know that is very bad practice because the changes will be gone after updating to a newer version but may be you can point me a little in the right direction of how I should do that the right way, if there is a way.
    Website is still under construction so it’s not possible to visit it but if it’s helpful I can post the code I altered.

    #1429821
    Barry
    Member

    Hi @sabinevi,

    Sounds like you have done a nice job so far!

    In terms of safely overriding the output of the generate_markers() method you can do so via the tribe_events_ajax_response hook. Simple example:

    add_filter( 'tribe_events_ajax_response', function( $data ) { 
        if ( empty( $data['markers'] ) ) {
            return $data;
        }
    
        foreach ( $data['markers'] as &$marker ) {
            // Change the following line to modify the markers as needed
            $marker = array_map( 'strtoupper', $marker );
        }
    
        return $data;
    } );
    

    That’s incomplete and untested, but should give the general idea. Does that help with your objectives?

    #1433521
    sabinevi
    Participant

    YES! Thank you very much Barry, problem solved

    #1433645
    Barry
    Member

    Awesome!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Overriding the generate_markers method’ is closed to new replies.