Home › Forums › Calendar Products › Events Calendar PRO › Help Adding Category To Tooltip But With…
- This topic has 17 replies, 2 voices, and was last updated 8 years, 1 month ago by Cliff.
-
AuthorPosts
-
February 18, 2016 at 4:17 am #1074828ShaunParticipant
I’m trying to customise my tooltip (shown when hovering over an event in main Calendar view) to include a ‘More Info’ link and a ‘Book Now’ link.
Because of the way I have my calendar set up the ‘More Info’ should link to the course category page (to save having to enter the same information every time and to prevent duplicate content on the site I enter the description on the category rather than actual event page) and the ‘Book Now’ links to the actual event where there is a form for booking.
I’ve edited month/tooltip.php to include the Book Now link using [[=permalink]]
I’ve also managed to get the category link into the Tooltip using [[=raw categories]] but that inputs the category title as the anchor text. So all I need now is to change the anchor text of that link to ‘More Info’ but I’ve hit a wall.
Example here: http://thorntonandlowe.com/training/month/
Any help would be much apprecaited.
February 18, 2016 at 11:51 am #1077335CliffMemberHi Shaun. I checked out your site: http://cl.ly/1M2k2e0l3B34
So in this screenshot, you’re wanting
February 25, 2016 #: ITT workshop
To become
February 25, 2016 #: More Info
?
If yes, please provide your code for month/tooltip.php (e.g. in a gist) so I can review and possibly help.
February 19, 2016 at 3:32 am #1077920ShaunParticipantHey Cliff,
Thanks for your reply.
That is correct. Well, also without the #: ideally. That is also added by the ‘[[=raw categories]]’ I’m using at the moment.
Appreciate your help!
February 19, 2016 at 11:01 am #1078385CliffMemberCould you please provide me the code you’re using so I can take a look and see what we’re working with?
Thanks a lot!
February 22, 2016 at 3:36 am #1079625ShaunParticipantSure.
So this is the contents of tooltip.php from the /month folder:
<script type="text/html" id="tribe_tmpl_tooltip"> <div id="tribe-events-tooltip-[[=eventId]]" class="tribe-events-tooltip"> <h4 class="entry-title summary">[[=title]]</h4> <div class="tribe-events-event-body"> <div class="tribe-event-duration"> <abbr class="tribe-events-abbr tribe-event-date-start">[[=dateDisplay]] </abbr> </div> [[ if(imageTooltipSrc.length) { ]] <div class="tribe-events-event-thumb"> <img src="[[=imageTooltipSrc]]" alt="[[=title]]" /> </div> [[ } ]] [[ if(excerpt.length) { ]] <p class="tribe-event-description">[[=raw excerpt]]</p> [[ } ]] [[ if(categories.length) { ]] <p class="tribe-event-categories">[[=raw categories]]</p> [[ } ]] <span class="tribe-events-arrow"></span> <p><a href="[[=permalink]]" class="url">Book Now</a></p> </div> </div> </script>
As you can see it’s the [[=raw categories]] code that is pulling in the event name/link.
That is defined in single-event.php, also in the /month folder where I have the following:
$day = tribe_events_get_current_month_day(); $event_id = "{$post->ID}-{$day['daynum']}"; $link = tribe_get_event_link( $post ); $title = get_the_title( $post ); $additional_data = array(); $categories = tribe_get_event_categories( $event_id, array( 'before' => '', 'sep' => ', ', 'after' => '', 'label' => '', // An appropriate plural/singular label will be provided 'label_before' => '', 'label_after' => '', 'wrap_before' => '', 'wrap_after' => '', ) );; $additional_data['categories'] = $categories
I have removed the ‘#’ from ‘label’ since my last post so that has been removed from the tooltip. But there is still a colon ‘:’ showing. And I don’t see anyway to control the anchor text of the link.
Hope you can help, thank you for trying!
February 22, 2016 at 2:17 pm #1080199CliffMemberFor our (and possibly others’) reference:
- Here’s the diff of what’s normally in /wp-content/plugins/the-events-calendar/src/views/month/tooltip.php vs your first snippet: https://www.diffchecker.com/lszynan5
- And the diff for the last few lines from /wp-content/plugins/the-events-calendar/src/views/month/single-event.php vs your second snippet: https://www.diffchecker.com/phqfeda2
The reason for that seemingly out-of-place colon is because you use tribe_get_event_categories() (see this link for the cause of the colon).
You could either filter the content (find and replace the colon) via tribe_get_event_categories filter.
Or you could set that ‘label_before’ argument, like this: http://cl.ly/1R3c3b14421d
I sure hope this helps!
Let me know if you need anything else.
February 23, 2016 at 2:54 am #1080579ShaunParticipantThanks for the reply Cliff.
I have read the links but haven’t come across anything relating to what I’m trying to achieve.
My main issue isn’t removing the colon but changing the anchor text of the category link.
Can you tell me if it’s possible to have the category link with custom anchor text of ‘More Info’ rather than automatically the category name?
Thanks again.
February 23, 2016 at 2:18 pm #1081005CliffMemberSo from http://cl.ly/1R3c3b14421d, you’re wanting “Cliff Test Category: Barbecue, Concert” to be “Cliff Test Category: More Info”?
February 24, 2016 at 1:47 am #1081297ShaunParticipantHi Cliff,
Ideally just the words ‘More Info’, doesn’t really need to category at all because the event title will always be the same or very similar.
But if what you suggests is the closest we can get I’d happily take it.
Thanks
February 24, 2016 at 6:44 am #1081396CliffMemberhttp://cl.ly/1M2k2e0l3B34 reads:
ITT Workshop (Birmingham)
February 25, 2016
#: ITT Workshop
Book NowHow would you want it to read???
February 24, 2016 at 7:01 am #1081399ShaunParticipantITT Workshop (Birmingham)
February 25, 2016
More Info
Book NowWith ‘More Info’ still linked to category and ‘Book Now’ still linked to single event page.
February 24, 2016 at 9:36 pm #1081847CliffMemberThanks. I better understand your request now.
- You’re using tribe_get_event_categories(), which isn’t really appropriate for static text linking because an event could have multiple categories.
- If you REALLY want to customize it, why not just set the “label” argument to “More info”?
I hope you get it working…
February 25, 2016 at 4:18 am #1081902ShaunParticipantWow. 7 days later – after you made me say the same thing five times – you tell me that it’s not actually possible?
Thanks for that.
February 25, 2016 at 1:06 pm #1082164CliffMemberSorry that last reply bummed you out.
(FYI: I saw you had a double-semi-colon at “) );;” near the end of your code snippet.)
I hope you understood where I was coming from…
Example: if an event is in Categories Abc and Xyz and you set the category link text to “More Info”, it would appear like this:
#: More Info, More Info
Might this be what you’re wanting?
February 26, 2016 at 8:33 am #1082439ShaunParticipantHi Cliff,
Thanks for your reply. I apologise if my previous response was a little snappy, maybe I misunderstood your comment?
Thanks for your continued support, that is EXACTLY what I was trying to achieve (well, without the ‘#:’ but that seems to have disappeared anyway!)
I understand that having multiple categories will create two ‘More Info’ buttons which wouldn’t be desired but actually I can’t think of a situation where I’ll have an event in multiple categories so it shouldn’t even be an issue.
Thanks again for your help, I really do appreciate it.
-
AuthorPosts
- The topic ‘Help Adding Category To Tooltip But With…’ is closed to new replies.