Home › Forums › Calendar Products › Community Events › iCal exported file seems to have the same number of lines no matter what
- This topic has 13 replies, 4 voices, and was last updated 10 years, 1 month ago by
Support Droid.
-
AuthorPosts
-
February 15, 2016 at 11:51 am #1073391
David Warner
ParticipantI 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?
February 16, 2016 at 10:00 am #1073896Hunter
ModeratorHey 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 🙂
February 16, 2016 at 10:08 am #1073898David Warner
ParticipantHere’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 );
}
?>February 17, 2016 at 11:38 am #1074612Hunter
ModeratorWelcome 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?
Try it out and let me know how it goes. Thanks for choosing PRO and have an excellent week 🙂
February 17, 2016 at 12:16 pm #1074625David Warner
ParticipantThat’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.
February 18, 2016 at 9:57 am #1077155David Warner
ParticipantOn 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.
February 23, 2016 at 10:16 am #1080869Hunter
ModeratorHey 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 🙂
February 29, 2016 at 11:12 am #1083482David Warner
ParticipantAny updates?
March 2, 2016 at 4:39 pm #1084636George
ParticipantHey 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,
GeorgeMarch 2, 2016 at 5:03 pm #1084645David Warner
ParticipantI 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.
March 3, 2016 at 10:41 am #1084932George
ParticipantHey 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
March 3, 2016 at 11:02 am #1084952David Warner
ParticipantThis 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:VCALENDARMarch 3, 2016 at 3:42 pm #1085074George
ParticipantThanks 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,
GeorgeMarch 18, 2016 at 9:35 am #1091052Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘iCal exported file seems to have the same number of lines no matter what’ is closed to new replies.
