iCal exported file seems to have the same number of lines no matter what

Home Forums Calendar Products Community Events iCal exported file seems to have the same number of lines no matter what

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1073391
    David Warner
    Participant

    I took the suggestion I read on here about creating your own plugin and then putting in the code that would allow a pull of 365 days of events in iCal format. URL is: http://www.artintheadirondacks.com/events/?ical=1&year-feed However, when you get that file, it doesn’t match up to the actual number of events. When I look at the iCal file, it’s only 166 lines of information. Before I put that code in, it did the same thing – about 166 lines were downloaded. http://www.artintheadirondacks.com/events/?ical=1 The date spread is larger when I put your code in and say 365 days, but the number of lines downloaded in the iCal file remains the same. BTW: the site is limited to US and Canada IP addresses – if you are in another country, it’s blocked. Any thoughts?

    #1073896
    Hunter
    Moderator

    Hey David,

    Sorry to hear about the troubles.

    Would you mind sharing a link to the article on creating the plugin as you mentioned? I’m having a difficult time tracking it down. Once I have that, I’ll be able to provide more assistance.

    Let me know and we’ll go from there. Thanks for choosing PRO and have a good day 🙂

    #1073898
    David Warner
    Participant

    Here’s the code from the link:

    <?php
    /*
    Plugin Name: AITA
    Description: Allows the Modern Tribe Events Calendar to pull a one year iCal feed.
    Version: 0.1
    License: GPL
    Author: David E. Warner
    Author URI: http://www.artintheadirondacks.com
    */
    add_action( ‘pre_get_posts’, ‘cliff_tribe_custom_time_range_ics_export’ );
    function cliff_tribe_custom_time_range_ics_export( WP_Query $query ) {
    if ( ! isset( $_GET[‘ical’] ) || ! isset( $_GET[‘year-feed’] ) ) {
    return;
    }
    if ( ! isset( $query->tribe_is_event_query ) || ! $query->tribe_is_event_query ) {
    return;
    }
    $query->set( ‘eventDisplay’, ‘custom’ );
    $query->set( ‘start_date’, ‘now’ );
    $query->set( ‘end_date’, ‘+ 365 days’ ); // http://php.net/manual/en/datetime.formats.relative.php
    $query->set( ‘posts_per_page’, -1 );
    }
    ?>

    #1074612
    Hunter
    Moderator

    Welcome back David,

    Thanks for sharing the code with me.

    Before I investigate the issue on my test environment, would you please try the following snippet in place of the one you’re using and see if it yields the results you’re looking for?

    https://gist.githubusercontent.com/cliffordp/ab1f7c4d95723ee6f892/raw/0446284650b79e01ed24b11482e55bec5d4ca121/functions.php

    Try it out and let me know how it goes. Thanks for choosing PRO and have an excellent week 🙂

    #1074625
    David Warner
    Participant

    That’s the same code, I just took the comments out. However, I copy and pasted it in. Both links (either the year or your standard one I listed above – please try them yourself) still give only about 162-166 lines of events.

    #1077155
    David Warner
    Participant

    On further examination (after putting all your new versions of the plugins up today) the problem still remains, but I have more data. I changed the number of events to view on a page from 16 to 30 thinking there might be a link. Then, I used the Export Listed Events button at the bottom of the page…It STILL only spit out 166 lines of events. So, there is something more going on in your iCal functionality than what I’m trying to do by showing a year’s worth of events.

    #1080869
    Hunter
    Moderator

    Hey David,

    Thanks for the updates. I’m going to do some testing on my local environment and consult with a few other team members on the matter and will get back to you with my findings as soon as possible.

    Thank you for holding tight and have a good week 🙂

    #1083482
    David Warner
    Participant

    Any updates?

    #1084636
    George
    Participant

    Hey David,

    Apologies for the delayed response here. I am working on this customized code, and am getting inconsistent results with my iCal output.

    I’m wondering—if you specify a high number for the ‘posts_per_page’ argument, instead of the current ‘-1’ value, does anything change with your output?

    So instead of this:

    $query->set( 'posts_per_page', -1 );

    This, for example:

    $query->set( 'posts_per_page', 300 );

    Thank you,
    George

    #1084645
    David Warner
    Participant

    I just tried that (cleared the cache) and had the same result. I’ve left the code with the 300 set if you want to export a file from the site by clicking on the Export Listed Events button.

    #1084932
    George
    Participant

    Hey David,

    I’ve done some experimenting and found some progress by ensuring that timestamps are returned instead of strings. To test this yourself, can you try finding these two lines of code:


    $query->set( 'start_date', 'now' );
    $query->set( 'end_date', '+ 365 days' );

    And using the strtotime() function on each parameter, so that those lines instead look like this:


    $query->set( 'start_date', strtotime( 'now' ) );
    $query->set( 'end_date', strtotime( '+ 365 days' ) );

    Let me know if this helps!

    — George

    #1084952
    David Warner
    Participant

    This is all it spits out from this URL (http://www.artintheadirondacks.com/events/?ical=1&year-feed) after the changes:

    BEGIN:VCALENDAR
    VERSION:2.0
    PRODID:-//Art in the Adirondacks – ECPv4.0.7//NONSGML v1.0//EN
    CALSCALE:GREGORIAN
    METHOD:PUBLISH
    X-WR-CALNAME:Art in the Adirondacks
    X-ORIGINAL-URL:http://www.artintheadirondacks.com
    X-WR-CALDESC:Events for Art in the Adirondacks
    END:VCALENDAR

    #1085074
    George
    Participant

    Thanks for testing this David. I’m baffled by why my results are so different from yours. At this point the best next step I can think of would be to do a thorough test for theme or plugin conflicts. It’s possible that one of these pieces of software on your site has its own WP_Query manipulation going on which is messing with things here—or something to this effect….

    To test for conflicts, I would recommend leaving your code as-is for now. Leave these plugins activated:

    • The Events Calendar

    Other than just that one plugin, deactivate every plugin on your site.

    What happens when you try to generate a year-of-events feed?

    If the result is the same, then I would recommend keeping things in this state and then activating a default theme like Twenty Sixteen.

    What happens when you try to generate a year-of-events feed?

    Let us know if you can do these steps, and if so, what you can find!

    Thank you,
    George

    #1091052
    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 14 posts - 1 through 14 (of 14 total)
  • The topic ‘iCal exported file seems to have the same number of lines no matter what’ is closed to new replies.