Help Adding Category To Tooltip But With…

Home Forums Calendar Products Events Calendar PRO Help Adding Category To Tooltip But With…

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #1074828
    Shaun
    Participant

    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.

    #1077335
    Cliff
    Member

    Hi 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.

    #1077920
    Shaun
    Participant

    Hey 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!

    #1078385
    Cliff
    Member

    Could 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!

    #1079625
    Shaun
    Participant

    Sure.

    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!

    #1080199
    Cliff
    Member

    For our (and possibly others’) reference:

    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.

    #1080579
    Shaun
    Participant

    Thanks 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.

    #1081005
    Cliff
    Member

    So from http://cl.ly/1R3c3b14421d, you’re wanting “Cliff Test Category: Barbecue, Concert” to be “Cliff Test Category: More Info”?

    #1081297
    Shaun
    Participant

    Hi 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

    #1081396
    Cliff
    Member

    http://cl.ly/1M2k2e0l3B34 reads:

    ITT Workshop (Birmingham)
    February 25, 2016
    #: ITT Workshop
    Book Now

    How would you want it to read???

    #1081399
    Shaun
    Participant

    ITT Workshop (Birmingham)
    February 25, 2016
    More Info
    Book Now

    With ‘More Info’ still linked to category and ‘Book Now’ still linked to single event page.

    #1081847
    Cliff
    Member

    Thanks. I better understand your request now.

    1. You’re using tribe_get_event_categories(), which isn’t really appropriate for static text linking because an event could have multiple categories.
    2. If you REALLY want to customize it, why not just set the “label” argument to “More info”?

    I hope you get it working…

    #1081902
    Shaun
    Participant

    Wow. 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.

    #1082164
    Cliff
    Member

    Sorry 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?

    https://gist.github.com/cliffordp/5ce1321df4f752beb30f#file-yourchildtheme-tribe-events-month-single-event-php-L14

    #1082439
    Shaun
    Participant

    Hi 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.

Viewing 15 posts - 1 through 15 (of 18 total)
  • The topic ‘Help Adding Category To Tooltip But With…’ is closed to new replies.