Show both past and future event pins on map view

Home Forums Calendar Products Events Calendar PRO Show both past and future event pins on map view

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1012646
    SEMANTICS
    Participant

    Dear friends,

    I’m really having trouble with showing pins of all past events on map view. You can see our web site here: http://www.mineralsday.eu/events/map/

    It only shows upcoming events on map with it’s pins. But our client wants to show all past events and it’s pins on map.

    We researched in the forum about it ald almost read all threads, applied something to functions.php but no way, we couldn’t success. Can you please help me asap with this. What code to insert and where exactly?

    Thank you very much.

    Best,
    Ahmet

    #1012649
    SEMANTICS
    Participant

    by the way, if you click on previous events link at the bottom of the page, it starts showing past events on map. I tried to increase events per page option to 100 but nothing changed.

    #1012945
    Nico
    Member

    Howdy Ahmet,

    Welcome to our support forums and thanks for reaching out to us. I’ll help you out on this one!

    What you describe is the default behavior of month view, I guess it’s possible to customize it to show also past events. While we cannot fully support clients customization request’s, here’s the code to modify the ‘map view’ query, you might need to play around a bit with it:


    add_action( 'tribe_events_pre_get_posts', 'modify_map_query' );
    function modify_map_query( $query ) {

    if ( defined( 'DOING_AJAX' ) && DOING_AJAX && $query->get('eventDisplay') == 'map' ) {

    // var_dump($query);
    // modify query parameters
    // $query->set('eventDisplay','past');
    }

    return $query;
    }

    Add this snippet to your theme’s functions.php file and inspect how the query is built and how it can be modified. You’ll see the results in the browser console, in the XHR panel (http://stackoverflow.com/questions/1535462/debug-xhr-in-chrome-browser/1591333).

    Please let me know if you can play around with that code a bit,
    Best,
    Nico

    #1013027
    SEMANTICS
    Participant

    Dear Nico,

    I inserted the snipped you gave me but nothing changed, you can see it here http://www.mineralsday.eu/events/map/

    Can you please tell me what’s wrong?

    #1013335
    Nico
    Member

    Hi Ahmet,

    Thanks for following-up on this! The code shared wasn’t intended to be a definitive solution but more of an starting point from which you can develop the customization you need for your website. I can take another look at this and run some quick tests next week but I can’t assure to craft this snippet if it takes too much time, as this is out of the support scope we can provide here.

    Have a great weekend, I’ll be back to you on Monday,
    Best,
    Nico

    #1013606
    SEMANTICS
    Participant

    Nico,

    Thank you very much for your helps. I will be really happy if you can do me a favor about solving that problem.

    Hope to hear from you soon.

    Thanks.

    #1013635
    SEMANTICS
    Participant

    Dear Nico,

    I used this snipped in my functions.php file and succeeded to list all past and upcoming events on map but also all past events are being listed on the list under the map now.

    So i want just like this, map will list all past and upcoming, and the list under it will show unly the upcoming ones.

    here is the code i’m using.

    add_action( ‘tribe_events_pre_get_posts’, ‘modify_map_query’ );
    function modify_map_query( $query ) {

    if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX && $query->get(‘eventDisplay’) == ‘map’ ) {

    $query->set( ‘posts_per_page’, -1 );
    $query->set( ‘start_date’, ‘1000-01-01’ );
    $query->set( ‘end_date’, ‘5000-01-01’ );
    }

    return $query;
    }

    #1013818
    Nico
    Member

    Hey Ahmet,

    Thanks for following up on this! Glad to see you could find a work around for this!

    To do so you’ll need to customize the template for the list part, as it pulls the events from the same source as the map. So I think the best solution here is to override the template that lists the events under the map and add a conditional there to prevent past events from showing up. I’ll outline the process to do the template override below but be sure to check our Themer’s guide first:

    – Create the following folder structure ‘tribe-events/pro/map/’ in your theme folder ‘wp-content/themes/your_theme/’.
    – Make a copy of the file ‘loop.php’ located at ‘wp-content/plugins/events-calendar-pro/src/views/pro/map/’.
    – Drop the copied file into the ‘tribe-events/pro/map/’ folder you just created in your theme.
    – Edit the copy of ‘loop.php’ like shown below:


    ...
    <?php if( strtotime(tribe_get_start_date(null, true, 'Y-m-d')) > time() ): ?>

    <?php do_action( 'tribe_events_inside_before_loop' ); ?>

    <!-- Event -->
    <div id="post-<?php the_ID() ?>" class="<?php tribe_events_event_classes() ?>">
    <?php tribe_get_template_part( 'pro/map/single', 'event' ) ?>
    </div><!-- .hentry .vevent -->

    <?php do_action( 'tribe_events_inside_after_loop' ); ?>

    <?php endif; ?>
    ...

    That will be prevent the ‘past’ events from being shown at all in the event list.

    Please let me know if this snippet gets the work done,
    Best,
    Nico

    #1018828
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Show both past and future event pins on map view’ is closed to new replies.