Support » Plugin: The Events Calendar » How to make website url under Events and Venues open in new tab/page?

  • Resolved sparky672

    (@sparky672)


    There is an optional field for a website URL under each Venue and also under each Event. However, there appears to be no way to make this URL open into a new tab or page. Is there a hidden setting or workaround?

    I know how to write HTML that makes anchor tags open into new windows, but these URL’s are automatically generated by this plugin.

    Thank you.

    • This topic was modified 2 years, 10 months ago by sparky672.
Viewing 12 replies - 1 through 12 (of 12 total)
  • I’d also love to hear the response to this one! I had the same question.

    Thread Starter sparky672

    (@sparky672)

    I ended up implementing a jQuery/JavaScript workaround that is injected by my child theme’s functions.php, which I think is a ridiculous and stupid hack; using PHP to inject jQuery that rewrites HTML on the client-side, HTML that should have been written correctly via PHP in the first place… LOL.

    1. There is no option within settings to make these URLs open in a new tab/page. Come on… seriously? Even if you don’t want to give the option, make it something that can be easily fixed via template, see #2…

    2. There is the ability to customize or over-ride all views for this plugin through child theme templates, so a solution should be fairly straightforward. However, the clickable links for these URLs are generated via a PHP function in the plugin, NOT through anything on any of the templates. Really? So now we have to come up with some kind of PHP function that over-rides the built-in PHP function. Ugh. I had no luck with this approach, see item #3…

    3. Okay… so just put a sensible workaround in your KB, right? There is NOTHING in the KB about this issue, but yet are at least a half dozen threads on the OP’s support forum asking for this to be an option. Some implemented a solution via their child-theme’s functions.php, but all threads were summarily closed without any complete code snippet that would solve this. Either that, the threads with code were just too old, or the code was incomplete and missing adequate explanation.

    Before I post my injected jQuery solution, I am really interested in the developer making an intelligent and thoughtful comment about this.

    Thank you.

    I will watch with anticipation for the reply from the developer(s). Have a client who will remove the calendar feature if this isn’t possible and it is a big part of the site and site use going forward as multiple other sites will also add the plugin. But not as is.

    Thread Starter sparky672

    (@sparky672)

    As long as you have a child-theme, and it’s using jQuery, my solution will work. I just think using PHP to inject JavaScript/jQuery to re-write HTML that is written by PHP in the first place is stupid and messy.

    Would love them to just add this feature yet until then do you have some code that has worked for you?

    Thread Starter sparky672

    (@sparky672)

    As long as you have a child-theme, and it’s using jQuery:

    // make all Events Calendar venue links open in new window/tab
    function wp_make_all_venue_links_open_in_new_window() {
    ?>
        <script>
            jQuery(document).ready(function($$){
    	    $$('.tribe-venue-url > a').attr('target', '_blank');
    	});
        </script>
    <?php
    }
    add_action( 'wp_footer', 'wp_make_all_venue_links_open_in_new_window' );

    Keep in mind the solution above depends on jQuery and it’s only targeting .tribe-venue-url > a, which are anchor tags as direct children of elements with the .tribe-venue-url class; so only the venue URL’s. You can modify this to include the event links by inspecting the DOM to get the class name and then target this class too.

    Again, this is a hack, and hopefully temporary; you are using PHP to inject a JavaScript to edit the HTML that was incorrectly created by the PHP in the first place. lol… very sloppy practice.

    • This reply was modified 2 years, 10 months ago by sparky672.

    Plugin Developer: do not close this thread. We await your direct input as to whether you’ll amp up your code and make this feature a reality.

    Look forward you your response.

    Thread Starter sparky672

    (@sparky672)

    This one is way better. Thank you @mathewlewis!

    Put this PHP code in your Child Theme’s functions.php file:

    // make all Events Calendar links open in new window/tab
    function blank_target_for_new_window() {
        return '_blank';
    }
    add_filter( 'tribe_get_venue_website_link_target', 'blank_target_for_new_window' );
    add_filter( 'tribe_get_event_website_link_target', 'blank_target_for_new_window' );

    No need for any jQuery or JavaScript manipulation of the DOM. This hooks into the PHP to generate the correct HTML markup in the first place.

    If the developer does not want to give us a checkbox option or setting, this is the cleanest next-best way to do it. However, based on my Google searching, the developer is getting more than enough requests for this feature for it to be incorporated into their official KB or FAQ pages… at the very least!

    • This reply was modified 2 years, 10 months ago by sparky672.

    Hey there,

    Thanks for reaching out 😄

    The solution that @sparky672 offered is exactly what we suggest. I’m not aware of any plans for this, but you can definitely submit a Feature Request.

    Take care,
    Ed 🤟

    Hey there,

    Since this topic has been inactive for a while, I’m going to go ahead and mark as resolved. Don’t hesitate to reopen or create a new topic if you still need help! 😄

    Take care,
    Ed 🤟

    Hi Ed

    Actually, I think it is almost unreasonable to not have an option to open a link in another tab/window.

    The majority of us realise that when having a link on your own website pointing to another website, you do not completely want to direct a viewer or potential customer, completely away from your own site. WordPress itself has the built in option to open a new tab so I see little reason not to include this in the calendar? I can hardly see this a major development, it’s more something very basic and somewhat expected as standard in any web development – to be able to open a page in a new window.

    I look forward to your response as to why you feel it hasn’t and won’t be included in a soon future update?

    Thanks

    Mike

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to make website url under Events and Venues open in new tab/page?’ is closed to new replies.