Add more details to calendar tooltip

WordPress Event Management, Calendars & Registration Forums General Question Add more details to calendar tooltip

This topic contains 6 replies, has 2 voices, and was last updated by  Stephen Harris 3 years, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #17312

    Hello. I am trying to add more details to the event tooltips on the calendar but there’s not enough documentation that could help me figure it out.
    I looked at a few other topics and read this page : http://codex.wp-event-organiser.com/hook-eventorganiser_event_tooltip.html but still no luck.

    I want the tooltip to show the following:

    Title
    Date
    Time
    Location/venue
    Category
    Hosted by (It’s a custom field I have added)

    Please show me how to achieve this.

    Thanks
    Mehrdad

    Mehrdad Emami
    #17318

    Please see this thread for getting the event category. Other details can be added as follows:

    add_filter( 'eventorganiser_event_tooltip', 'my_callback_function', 10, 4 );
    function my_callback_function( $description, $event_id, $occurrence_id, $post ){
    
        $title = 'Title: ' . get_the_title( $event_id );
        $date = 'Date: ' . eo_get_the_start( 'jS F Y', $event_id, null, $occurrence_id );
        $time = 'Time: ' . eo_get_the_start( 'g:ia', $event_id, null, $occurrence_id );
        $venue = 'Venue: ' . eo_get_venue_name( eo_get_venue( $event_id ) );
        $custom_field = 'Custom field: ' . get_post_meta( $event_id, 'my_field', true );
    
        $description = $title . '<br>' . $date . '<br>' . $time . '<br>' . $venue . '<br>' . $custom_field . '<br>' . $description;
    
        return $description;
    
    };
    

    Please note that the calendar is cached, changes won’t take effect until you update an event.

    • This reply was modified 3 years, 9 months ago by  Stephen Harris.
    Stephen Harris
    #17320

    Thanks for the code, It works for the title and venue but date and time are only showing as follows
    (Empty)
    Date:
    Time:

    However I managed to achieve some of it by using another method, by editing the event-organiser-ajax.php on line 202 to the following:

    $description = ‘‘ . genesis_get_custom_field( ‘real-date’ ) . ‘‘ . ‘Time: ‘ . genesis_get_custom_field( ‘time_info’ ) . ‘‘ . ‘

    <div class=”location-tip”>’ . ‘Location: ‘ . genesis_get_custom_field( ‘custom-location’ ) . ‘</div>

    ‘ . ‘

    <div class=”host”>’ . ‘‘ . genesis_get_custom_field( ‘host_tooltip’ ) . ‘</div>

    ‘ . ‘

    <div class=”tool-description”>’.$description.'</div>

    ‘ ;

    Not sure what the difference is between these two methods because I am not good at PHP.
    But there is one custom field that I haven’t been able to display.

    It’s basically a post object custom field where I display posts from another post type.
    I have been able to display the value in my template by adding the following code in my template:

    <?php foreach(get_field(‘hosted_by’) as $post_object): ?>
    ID); ?>”>Hosted by: <?php echo get_the_title($post_object->ID) ?>
    <?php endforeach; ?>

    But how can I also display this in the tooltip? it was not possible to add the foreach inside my code.
    It’s a bit tricky. at least for me.

    Any idea?

    Thanks so much!

    Mehrdad Emami
    #17321

    Opps! I realized the code was changed as I posted my reply.

    I try again:

    The code I’m using for the tooltip in event-organiser-ajax.php:

    $description = '' . genesis_get_custom_field( 'real-date' ) . '' . 'Time: ' . genesis_get_custom_field( 'time_info' ) . '' . '<div class="location-tip">' . 'Location: ' . genesis_get_custom_field( 'custom-location' ) . '</div>' . '<div class="host">' . '' . genesis_get_custom_field( 'host_tooltip' ) . '</div>' . '<div class="tool-description">'.$description.'</div>' ;
    

    The code I’m using in my template:

    <?php foreach(get_field('hosted_by') as $post_object): ?>
        ID); ?>">Hosted by: <?php echo get_the_title($post_object->ID) ?>
    <?php endforeach; ?>
    
    Mehrdad Emami
    #17322

    Still looks not right.
    Anyways. let me know if that makes sense or there’s any other way I can post the code correrctly here.

    Mehrdad Emami
    #17323

    You’re printing with echo – you want to concatenate the string to $description.

    R.e. my previous post, my calls to eo_get_the_start() were incorrect,

     eo_get_the_start( 'jS F Y', $event_id, $occurrence_id )
    

    should be

    eo_get_the_start( 'jS F Y', $event_id, null, $occurrence_id )
    

    and similarly for the time.

    The additional null value is required for backwards compatibility which is being dropped in 3.0.0. In short the second works now and for future version, the first will work from 3.0.0+.

    Please note that any changes made to the plug-in files will be lost when (if) you update.

    I’ve since edited my original answer.

    • This reply was modified 3 years, 9 months ago by  Stephen Harris.
    Stephen Harris
    #17326

    Just so you know the forums use markdown. Or you can just type the code ‘as is’, highlight it, and click the braces icon ({}).

    Stephen Harris
Viewing 7 posts - 1 through 7 (of 7 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.