Add meta data from other posts to event in week view

Home Forums Calendar Products Events Calendar PRO Add meta data from other posts to event in week view

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1119723
    Matthias
    Participant

    Hey there

    I have a calendar with several events in a week view. Now I wanted to add additional information to the event:

    – A “Buy” button for the attached ticket from your ticket plugin
    – A String that is coming from another post, that is related to the event post. The post id of this other post is saved in the events post metadata

    So far I tried to catch this additional data in the single-event.php. But somehow I can’t catch it. What is a good way to get this information into the events?

    Thanks,
    Matthias

    #1119979
    Brian
    Member

    Hi,

    Thanks for using our plugins. I can help out here.

    We are limited in supporting customizations, but I can help you get started.

    I found this thread that goes over the Process of adding content there, that might be able to help you out:

    Add Organizer, Venue and Price info to tooltips in Week and Month view

    I can try to help out with a couple more questions from here, but unable to provide all the coding for a customizations.

    Thanks

    #1120413
    Matthias
    Participant

    Hey Brian

    Thanks for your answer. I included the plugin that should expand the entries of the json file with the additional event information. And I also changed the tooltip.php to display the additional information. But there is nothing showing up in the tooltip. How is this templating system working. And where would be a good point to debug the additional information?

    Thanks,
    Matthias

    #1120597
    Brian
    Member

    Hi,

    For a reference of our template system please review the themer’s guide:

    https://theeventscalendar.com/knowledgebase/themers-guide/

    https://theeventscalendar.com/knowledgebase/template-overview/

    As well as the contents of this file have a good guide to it:

    plugins/events-calendar-pro/src/views/pro/week/single-event.php

    I changed things around a bit from that snippet to just overwrite the file directly and I added this to my child theme’s functions.php:


    class TEC_Forum_9453495 {
    public static $ID = 9453495;
    public static $_instance = null;
    public function __construct(){
    add_filter( 'tribe_events_template_data_array', array( __CLASS__, 'template_data_array' ), 10, 3 );
    }
    public static function instance(){
    if ( ! is_a( self::$_instance, __CLASS__ ) ) {
    self::$_instance = new self();
    }
    return self::$_instance;
    }
    public static function template_data_array( $json, $event, $additional ){
    $json['venue'] = '';
    $json['organizer'] = '';
    $json['price'] = '';
    $venue = tribe_get_venue_id( $event );
    if ( $venue ){
    $json['venue'] = $venue;
    $json['venue_link'] = tribe_get_venue_link( $venue, false );
    $json['venue_title'] = tribe_get_venue( $venue );
    }
    $organizer = tribe_get_organizer( $event );
    if ( $organizer ){
    $json['organizer'] = $organizer;
    }
    if ( function_exists( 'wootickets_init' ) && false === true ){
    $tickets = TribeWooTickets::get_instance()->get_tickets_ids( $event );
    if ( ! empty( $tickets ) ){
    $min = PHP_INT_MAX;
    $max = -1;
    foreach ( $tickets as $ticket ) {
    $ticket = TribeWooTickets::get_instance()->get_ticket( $event, $ticket );
    $min = min( array( $min, $ticket->price ) );
    $max = max( array( $max, $ticket->price ) );
    }
    if ( $min == $max ){
    $json['price'] = wc_price( $min );
    } else {
    $json['price'] = 'from ' . wc_price( $min ) . ' to ' . wc_price( $max );
    }
    }
    }
    return $json;
    }
    }
    TEC_Forum_9453495::instance();

    Then I replaced the contents of this file:

    themes/child/tribe-events/pro/week/tooltip.php

    With this:


    <?php

    /**
    *
    * Please see single-event.php in this directory for detailed instructions on how to use and modify these templates.
    *
    */

    ?>

    <script type="text/html" id="tribe_tmpl_tooltip">
    <div id="tribe-events-tooltip-[[=eventId]]" class="tribe-events-tooltip">

    [[=title]]

    <div class="tribe-events-event-body">
    <div class="duration">
    <abbr class="tribe-events-abbr updated published dtstart">[[=dateDisplay]] </abbr>
    </div>
    [[ if(imageTooltipSrc.length) { ]]
    <div class="tribe-events-event-thumb">
    [[=title]]
    </div>
    [[ } ]]
    [[ if(excerpt.length) { ]]
    <p class="entry-summary description">[[=raw excerpt]]</p>
    [[ } ]]
    [[ if(venue) { ]]
    <div class="entry-venue">Venue: [[=venue_title]]</div>
    [[ } ]]
    [[ if(organizer) { ]]
    <div class="entry-organizer">Organizer: [[=raw organizer]]</div>
    [[ } ]]
    [[ if(price) { ]]
    <div class="entry-price">Price: [[=raw price]]</div>
    [[ } ]]
    <span class="tribe-events-arrow"></span>
    </div>
    </div>
    </script>

    That showed the content (venue and organizer ) for me in the Week View Tooltip.

    #1127344
    Support Droid
    Keymaster

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Add meta data from other posts to event in week view’ is closed to new replies.