Home › Forums › Calendar Products › Events Calendar PRO › Event details page – open "Website:" in new window
- This topic has 14 replies, 5 voices, and was last updated 8 years, 1 month ago by Support Droid.
-
AuthorPosts
-
February 21, 2016 at 4:46 pm #1079522ToddParticipant
I’d like to have the “Website:” links on the Event details page open in new windows. I tried the code on this page, but it did not work:
https://gist.github.com/theeventscalendar/aacd642414ed838aecb7When I “Inspect” it’s easy to see the: target=”_self” , but I cannot find this code in the plugin files.
February 22, 2016 at 3:33 pm #1080259CliffMemberHi Todd. Thanks for including that link.
I assume you obtained it from our KB article about this topic.
I’ll flag our KB authors, but that snippet is outdated now. If you look in /wp-content/plugins/the-events-calendar/src/functions/template-tags/link.php, there’s now a filter specifically for this purpose: tribe_get_event_website_link_target
Here’s a snippet to leverage it:
Here: https://gist.github.com/cliffordp/3584b8aee70cde484700
Please let me know how things go for you.
March 2, 2016 at 1:27 pm #1084551ScottParticipantOn the link.php I was able to change
apply_filters( 'tribe_get_event_website_link_target', '_self' ),
to
apply_filters( 'tribe_get_event_website_link_target', '_blank' ),
and it worked perfectly. I tried the same thing with general.php but did not have the same effect for Organizer or Venue website links. How can we have those open in new windows as well?
March 2, 2016 at 7:15 pm #1084671ToddParticipantCliff,
That worked for the Details Website link. Thank you!
I’d also like the Venue Website link to open in a new window. Is there a filter for that? Or, can you assist us in creating a filter?
Example: http://www.coloradograndparent.com/event/rhino-meet-and-greet/2016-03-30/
I’d like the denverzoo.org link to open in a new window.Thanks!
March 7, 2016 at 5:09 pm #1086089BrookParticipantHowdy Todd,
Definitely we can help. It’s the exact same principle, only you are targeting the filter ‘tribe_get_venue_website_link_target’ instead. Set that _blank like you did with the event website and you’re golden.
That what you needed?
Cheers!
– Brook
March 7, 2016 at 6:52 pm #1086131ToddParticipantBrook,
Is there already the filter ‘tribe_get_venue_website_link_target’? I can’t find it in /wp-content/plugins/the-events-calendar/src/functions/template-tags/link.php. If so, where is it? If not, do I copy lines 293-308 in the link.php file and change the filter to ‘tribe_get_venue_website_link_target’?
Thanks,
Todd
March 7, 2016 at 7:00 pm #1086132ToddParticipantBrook,
Ah ha. I took a second look and found the filter in /wp-content/plugins/the-events-calendar/src/functions/template-tags/venue.php.
Line 414:
apply_filters( ‘tribe_get_venue_website_link_target’, ‘_self’ ),
Changed to:
apply_filters( ‘tribe_get_venue_website_link_target’, ‘_blank’ ),Thanks!
Todd
March 10, 2016 at 8:54 am #1087258CliffMemberThanks for your patience during the time we were closed.
Todd, you should NOT edit that venue.php file. If you do, your changes will be lost the next time you update the plugin.
Instead, best practice for adding custom code (like to implement a PHP snippet to modify The Events Calendar) is to create a functionality plugin, unless it’s something specific to your theme, in which case best practice is to make sure you’re using a child theme, then add the customization to your child theme’s functions.php file.
===
So, in your case, use the Gist code from my first reply as a template:
- replace “tribe_get_event_website_link_target” with “tribe_get_venue_website_link_target”
- replace “cliff_open_event_website_links_in_new_window” with something like “cliff_open_event_venue_links_in_new_window” — in both places
So you can have both my Gist code snippet AND your new snippet (in your theme’s functions.php file, for example) so that both Event Website links and Venue Website links open in a new window.
I hope this information helps!
March 10, 2016 at 10:22 am #1087321ToddParticipantThanks, Cliff.
I see what you mean. I will add the filter to my child theme’s function.php file.
Todd
March 10, 2016 at 10:47 am #1087327CliffMemberThanks. Let us know if you need anything else.
March 11, 2016 at 9:52 am #1087821ScottParticipantHi Cliff, I am still lost. I have this at the bottom of my functions.php file:
/* * The Events Calendar Open gCal Links in New Windows * @version 3.10 */ add_action( 'tribe_events_single_event_after_the_meta', 'tribe_open_gcal_new_tab' ); function tribe_open_gcal_new_tab() { echo '<script> /* Open gCal Links in New Windows */ jQuery("a.tribe-events-gcal") .addClass("external") .click( function() { window.open(this.href); return false; }); </script>'; } <?php /** * From https://gist.github.com/cliffordp/3584b8aee70cde484700 * * Open Event Website links in new window (not Organizer or Venue website links) * Filter is found in * /wp-content/plugins/the-events-calendar/src/functions/template-tags/link.php * and * /wp-content/plugins/events-calendar-pro/src/functions/template-tags/general.php */ add_filter( 'tribe_get_venue_website_link_target', 'cliff_open_event_venue_links_in_new_window' ); function cliff_open_event_venue_links_in_new_window() { return '_blank'; }
And yet the only link that opens in a new window is the Details website. What am I missing?
Thank you,
Scott
For some reason when I posted this it changed the code but I have copied and made the changes as per this discussion. Example page: https://www.coconutgrovechamber.com/event/starlight-movie-classics-sunday-march-6/
March 11, 2016 at 2:21 pm #1087997CliffMemberHi Scott. Yes, your code snippet got mangled by our forum…
Anyway, I think this is what you’re actually wanting:
Here: https://gist.github.com/cliffordp/3584b8aee70cde484700
Let me know.
March 19, 2016 at 8:11 am #1091343ScottParticipantUnfortunately that breaks the site, not all the pages, but most. When I try and go to the events page it show nothing but a blank page. Weird. I can live with it but maybe this is an option you could build into the next version where you have the option to open the link in a new window. If you have time to think of another way to do it, great! But if it’s something to do with my theme, I understand.
Scott
March 20, 2016 at 6:16 pm #1091626CliffMemberSorry that happened. I tested it on my local site and it worked just fine so there could be some conflicts going on.
Please follow our Testing for Conflicts Guide and see if that helps narrow down the cause of this. Hopefully it’ll work with a WordPress default theme like Twenty Fifteen and all other plugins inactive.
As far as an option, I’m pretty sure we won’t be adding that since there’s already a way to do it via hooks — just from my experience with how the development team evaluates such requests. If you really feel strongly about having it as a GUI setting, you can submit it to our UserVoice page.
If you post it, feel free to link to it from here in case anyone comes across this forum thread in the future.
Thanks.
April 4, 2016 at 9:35 am #1097971Support DroidKeymasterThis 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. -
AuthorPosts
- The topic ‘Event details page – open "Website:" in new window’ is closed to new replies.