iCal plugin and custom fields

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 11 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8560

    Hi!
    I have an ical-feed from an ticketing service that event organiser automatically gets it´s data from. The ticketing service that we are using has added “sales” information to the ical-feed “summary” field. This field also contains the the event heading. The summary field is now showing “EVENT or SHOW NAME” + “Tickets are available or No Tickets are available”.

    Now i would replace the textinformation “Tickets are available or No Tickets are available” text with an icon/image. This could be done with css. However the event title is on the same textfield.

    Is it possible to add separate fields to the ical-feed from the ticket office, that event organiser can then later add?

    Any suggestions how to solve this?

    Thanks for any suggestions!

    Niklas Forsberg
    #8580

    Hi Niklas,

    I’ll be adding filters to imported feeds that will make this task a bit better, but here’s a solution for now

    add_filter( 'the_content', 'niklas_reaplce_text_with_icon' );
    function niklas_reaplce_text_with_icon( $content ){
        if( 'event' == get_post_type() ){
           //Path to icons used. Assumed wp-content/[theme-name]/img/[icon].png
           $icon_tickets_available = get_stylesheet_directory_uri()."/img/icon-tickets-available.png";
           $icon_tickets_unavailable = get_stylesheet_directory_uri()."/img/icon-tickets-unavailable.png";
    
           $content = str_replace( 
                 "Tickets are available",
                 "",
                $content
           );
    
           $content = str_replace( 
                 "Tickets are unavailable",
                 "",
                $content
           );
        }
    
        return $content;
    }

    (Please note, this is completely untested).

    Why would doing this as the event is imported be better?

    1. the_content runs on the front-end. In the text editor you’ll still see the text.
    2. It’s something which can be done earlier (i.e. when the event is imported) – so by doing it on the front-end as the page loads for a visitor is doing unnecessary work.

    The above mentioned filters should be added in Event Organiser 2.7. In the mean time, I hope that helps!

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 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.