Open Event Website URLs in new window from monthly calendar view

Home Forums Calendar Products Events Calendar PRO Open Event Website URLs in new window from monthly calendar view

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1338706
    Mark Mosher
    Participant

    Hi,

    Our calendar has a mix of internal and external events:
    http://honens.archwebdev.com/events/complete-calendar/?tribe-bar-date=2017-09

    I added a function so that from the monthly calendar view, events with an Event Website URL will link directly to that external website, as described here:
    https://theeventscalendar.com/knowledgebase/make-links-event-go-straight-event-website/

    Now we’d like to be able to open external URLs in a new window by default. I added the filters below to our functions.php but it’s not working. The links still open in the same window.

    https://theeventscalendar.com/support/forums/topic/event-detail-page-url-should-contain-target_blank/

    Can you please let me know how to open external URLs in new windows from the monthly calendar view?

    Thanks!

    #1339481
    Victor
    Keymaster

    Hi Mark!

    Thanks for reaching out to us! I’d be happy to help you with that.

    There is no straight away method to make that happen. You would have to make a template override of the single-event.php template file located at /wp-content/plugins/the-events-calendar/src/views/month/

    We have a great article that will guide you on customizing our templates here > https://theeventscalendar.com/knowledgebase/themers-guide/

    I hope that helps! Let me know if you have other questions.

    Best,
    Victor

    #1340608
    Mark Mosher
    Participant

    Hi Victor,

    I see the line in the single event template that I’d need to change but I know how to edit this so that it only opens the link in a new window if the event has an Event Website URL, NOT if it’s linking to the internal event page.

    Can you share how to conditionally set the link window to new if there’s an Event Website URL entered for the event?

    <div id=”tribe-events-event-<?php echo esc_attr( $event_id ); ?>” class=”<?php tribe_events_event_classes() ?>” data-tribejson='<?php echo esc_attr( tribe_events_template_data( $post ) ); ?>’>

    ” class=”url”><?php echo $title ?>

    </div><!– #tribe-events-event-# –>

    Thanks!

    #1341105
    Victor
    Keymaster

    Hi Mark,

    Thanks for following up with this. Let me help you with that.

    First, please note that we are limited in how much support we can give for custom development questions like this. That said, we always like helping out and at least point users into the right direction.

    So, I managed to come up with a template override for the single-event.php template file that will output the event website url if present. In addition to this template override you should also place some code in your theme’s functions.php file to make it open into a new tab and also show the event title.

    Try the following code in here and let me know if it works for you:

    https://gist.github.com/vicskf/7e50310444cc3f0591b0adcc1c71db55

    Best,
    Victor

    #1342760
    Mark Mosher
    Participant

    Hi Victor,

    Thanks very much for that code. Worked like a charm! We appreciate your time to help.

    #1342766
    Victor
    Keymaster

    Hi Mark!

    I’m glad it worked out for you! Thanks for following up to let us know about it 🙂

    I’ll close this now, but feel free to open a new thread when needed and we’d be happy to help.

    Cheers,
    Victor

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Open Event Website URLs in new window from monthly calendar view’ is closed to new replies.