WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Request: ICS Export per category (10 posts)

  1. BertvanDorp
    Member
    Posted 1 year ago #

    Using the Events Manager for a month now, and love the simplicity, extendibility and just the fact that someone made this for me to use :-) Thanks!

    As of now, there's multiple .ICS export locations:
    e

    • [site]/index.php/events/events.ics
    • [site]/index.php/events/[events-category]/events.ics

    However, both of these files/links produce the same calendar, with all of the events. I'd like to be able to export just a certain category, and I'm willing to pay someone for this functionality as well as I'm not really experienced with JavaScript and PHP as of now. I'm assuming it's a matter of implementing a filter in the export functionality?

    Thanks in advance. And keep up the great work!

    EDIT: from another thread, I learned that the iCal output is being generated with /template/ical.php

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 1 year ago #

  3. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    at the moment, there isn't any function in EM to exports feeds with only one category, you'd need to modify the ical templates

    wasn't aware that both urls would produce an ical, i think that's just a coincidence, but maybe something we can take advantage of in the future when implementing this feature :)

  4. BertvanDorp
    Member
    Posted 1 year ago #

    @agelonwl thanks! will look into it. Seems I need to add arguments to the call, and filter based on the category in the argument.

    @Marcus: I guess this will provide helpful for a lot of users, as the site can actually offer a limited subscription. I don't have the time nor the resources to tackle this for the coming months. However, I'm willing to look into the filtering, see if there's a way. Do you have any pointers on using the fact that the category also generates the ical needed?

  5. BertvanDorp
    Member
    Posted 1 year ago #

    Followed up in the other thread: click.

  6. BertvanDorp
    Member
    Posted 1 year ago #

    Whoa, I got the thing to work! Thanks to the other thread and some trial-and-error on formatting. Funny thing is that this way actually uses the name of the category to generate the category id and filter on this, so this can be used as a general implementation! I added handling for permalinks as well. Here's the code:

    /* Get the category ID */
    $uri=$_SERVER['REQUEST_URI'];
    $args=explode('/',$uri);
    /* handling different permalinks */
    if ($args[1]=='index.php') {
    	$start_index_URI=2;
    }else{
    	$start_index_URI=1;
    }
    /* retrieve category ID from WP Events Manager DB */
    if($args[$start_index_URI]=='events' && $args[$start_index_URI + 1]=='categories') {
    	$cat_name=$args[$start_index_URI + 2];
    	$cat_obj=get_term_by('name', $cat_name , 'event-categories');
    	$cat_id=$cat_obj->term_id;
    }

    and the loop on (former) line 13:
    $EM_Events = EM_Events::get(apply_filters('em_calendar_template_args',array( 'limit'=>get_option('dbem_ical_limit'), 'owner'=>false, 'orderby'=>'event_start_date', 'scope' => get_option('dbem_ical_scope'), 'category'=>$cat_id )) );

    So, there's now three ways to get an export:
    1. per event
    2. per category: [site]/events/categories/[category name]/events.ics
    3. whole calendar: [site]/events/events.ics

    Marcus, I guess this is something you can just implement and document? It also works with different permalinks, as stated before.

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    glad you got it working on your site but to implement this, problem with the above is it probably won't not work in all cases, e.g. if permalinks are disabled. we'd need to look at $WP_Query and decide that way.

    since you can override the ical template I advise you copy that to your theme so you won't lose changes on updates

  8. BertvanDorp
    Member
    Posted 1 year ago #

    Did that, thanks Marcus!

  9. Rich
    Member
    Posted 1 year ago #

    I've been trying to get this to work but can't see whereabout in the ical.php file I would need to place this code. Any chance of a pointer?

    Thank you in advance,

    Richard

  10. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    probably first snippet at the top of the file, then the second bit on the line he mentioned (you probably replace a line there)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic