ical export issues

This topic contains 4 replies, has 2 voices, and was last updated by  Shimrit Elisar 8 years, 12 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #16387

    Hi there,

    I am trying to export my feed as an ical and am having two problems:

    1. Long descriptions get truncated
    2. HTML links present in the original description get stripped

    I am importing into a 3rd party html5 app creator site, but have had no issues importing rich text ical feeds before.

    Any help with these two issues much appreciated.

    Thanks!

    Shimrit Elisar
    #16423

    Hi Shimrit,

    By default the excerpt is used for the event content in the iCal feed. You can change this in one of two ways.

    1. Copy the ical.php template into your theme and edit (see this line – you can replace get_the_excerpt() with get_the_content().

    2. Or you can use the filter eventorganiser_ical_description.

    e.g.

    add_filter( 'eventorganiser_ical_description', 'my_set_ical_event_description' );
    function my_set_ical_event_description(){
          $description = wp_strip_all_tags( html_entity_decode( get_the_content(), ENT_COMPAT, 'UTF-8' ) );
          $description = ent2ncr( convert_chars( $description ) );
          return $description;
    }
    

    You’ll notice that I’ve stripped HTML tags in the above. This brings me to your second point. The iCal specification doesn’t mention HTML anywhere, so some calendar clients, when they receive HTML in event content simply treat it as text. For this reason, the HTML is stripped out.

    For calendar clients that support it there is a X-ALT-DESC;FMTTYPE=text/html tag which contains the full event content in HTML.

    If your calendar client does not, then you can use the above filter (or edit the template) to ensure that the HTML is not stripped out, but just keep in mind that some calendar clients will display the HTML tags rather than render them.

    Stephen Harris
    #16430

    Hey,

    Thank you very much for the detailed reply! Could you please let me know exactly how the edited template above should look if I remove the HTML stripping? I don’t know php so when I tried to remove bits, it broke the feed 🙂

    Thanks again,

    S

    Shimrit Elisar
    #16452

    Something like:

    add_filter( 'eventorganiser_ical_description', 'my_set_ical_event_description' );
    function my_set_ical_event_description(){
          $description =  get_the_content();
          $description = ent2ncr( convert_chars( $description ) );
          return $description;
    }
    

    should work, but it would depend on what your calendar is expecting.

    Stephen Harris
    #16544

    Thanks! It worked 🙂

    Shimrit Elisar
Viewing 5 posts - 1 through 5 (of 5 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.