Help Desk

Great news (feed from other TEC site) but limit of 3 months?

  • Posts: 67 Topics: 20
    | Permalink

    Thank you very much indeed for the new version and the fantastic facility to import from another Event Calendar website. This solves SO many issues (venues, maps, organisers, tags, excerpts and more!): thank you!

    I do however need to import more than the next 3 months, which I note has been set as a limit. The nature of our business means we have events up to 2 or 3 years ahead (but 2 years from today would be fine as a limit).

    Is there a way around this? I have found various snippets and code to download but am not sure if these are current, given the new version? I notice that the normal ical feed import still provides all the events displayed on the list page (number of events displayed) and it would be wonderful if this could be allowed for the “other url” feed too? Or at least to be able to override the default max of 3 months somehow?

    Many thanks for your help

    Posts: 1
    | Permalink

    I’am also very interested in a “way around”, because we have the exact same issue 🙂

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    Hi!

    You can increase the options available to you in the Events → Settings → Imports → Import Date Range field with a snippet like this one, which could be added to a custom plugin or even to your theme’s functions.php file if you prefer that approach:

    function extra_other_url_import_ranges( array $ranges ) {
    	$ranges[ MONTH_IN_SECONDS * 6 ] = array( 
    		'title' => 'Six months',
    		'range' => 'six months',
    	);
    
    	$ranges[ MONTH_IN_SECONDS * 12 ] = array( 
    		'title' => 'One year',
    		'range' => 'one year',
    	);
    
    	$ranges[ MONTH_IN_SECONDS * 18 ] = array( 
    		'title' => 'Eighteen months',
    		'range' => 'eighteen months',
    	);
    
    	$ranges[ MONTH_IN_SECONDS * 24 ] = array( 
    		'title' => 'Two years',
    		'range' => 'two years',
    	);
    
    	return $ranges;
    }
    
    add_filter( 'tribe_aggregator_url_import_range_options', 'extra_other_url_import_ranges' );

    You can of course modify to suit. Do bear in mind, though, that the sites you are importing from are not guaranteed to honour your request for a certain number or range of events: some hosting environments may lack the “power” to do so or it could even be that the site owner has added restrictions to better protect themselves.

    I hope that helps 🙂

    Posts: 67 Topics: 20
    | Permalink

    Thank you very much Barry and I am really pleased this is going to be possible. Excellent!
    I do however have a small problem as shown in the screenshot attached. I don’t want to guess as to how to correct it – are you able to advise (see error message)? Thanks!
    Error:
    The snippet has been deactivated due to an error on line 3:
    syntax error, unexpected ‘=’, expecting ‘)’

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    Sure: if you compare the code in your screenshot with the code in my last reply, you can see that instead of the > character you have > – this might be due to the way you copied and pasted the code.

    Correcting each so that instead of => you have => would be the way to go, here.

    Does that help?

    Posts: 67 Topics: 20
    | Permalink

    Thank you Barry and my apologies, as I should have spotted that!
    The code is now working, in that it is a) accepted without an error message and b)opens up the additional choices in the drop down box for the various periods. So far, so good… but:
    The import does not, however, then bring in the additional – longer – period. I have tried this on two different (import destination) sites, both of which are using the main agency site of tashmina.co.uk (my main website) as the source for the import.
    You mentioned the source website might not have the resources to furnish the request, or might have a built in control, but as it is my site I do know that it has pretty good hosting and there are no special controls in place as far as I am aware!
    Perhaps I need to make a change to the actual url I use too? Can you advise? Or what should I check next?
    Thanks!

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    If you’re in control of both sites you could add a snippet like this to the ‘source’ site:

    function increase_rest_event_max_per_page() {
        return 250;
    }
    
    add_filter( 'tribe_rest_event_max_per_page', 'increase_rest_event_max_per_page' );

    The value 250 is one you can play with and dictates the maximum number of events/posts that will be returned via the JSON API.

    I do advise proceeding with caution, though, as of course if this is too large of a number (and if you have lots of events within your database) there could be consequences in terms of site performance and/or the result may be it returns nothing at all, should total available memory be insufficient.

    Posts: 67 Topics: 20
    | Permalink

    Hi Barry – I have tried this but still no joy: the option for longer periods is presented but then ignored by the import, even though I have added the snippet you kindly provided to the source site.

    Hmmnn – what next… sadly 3 months doesn’t help me at all. We don’t have masses of events but they ARE spread out over a long period – 2 years forward normally….. but we are talking about events in their tens rather than in their hundreds…

    What next? Has anyone managed to get more than 3 months to import from “other url”? Perhaps I have to adapt the url itself in some way??

    Thank you and am really hoping there will be a solution: I have been looking forward to this release for a long time as it will (could) solve so many issues in our workflow but the 3 months limit is a real problem……..

    Any further words of wisdom much appreciated – thanks Barry!

    Posts: 67 Topics: 20
    | Permalink

    Hi – any further ideas on this anyone? I am really stuck if we can’t import more than 3 months! There are so many inbuilt problems with using ical between TEC sites and the new “other url” is fantastic BUT not if we can only import three months!

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    Hi – our apologies for the delay.

    Simply because this is a new system and because in this case we’re looking at modifying the default behaviour with custom code, it might take us just a little longer to get back to you.

    Do bear with us, though, and thank you for your patience!

    Posts: 67 Topics: 20
    | Permalink

    Hi Barry – many thanks indeed and I am really pleased you are looking into it. Superb service as ever!

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    Thanks for bearing with us 🙂

    Also, my apologies – I missed a trick with the initial snippet I shared. In addition to what I shared on 8th May, please also add this to the site initiating the import (the destination site):

    function support_long_other_url_import_ranges() {
    	return MONTH_IN_SECONDS * 24;
    }
    
    add_filter( 'tribe_aggregator_url_import_range_cap', 'support_long_other_url_import_ranges' );

    This compliments but does not replace the other snippet. Can you give that a whirl? Based on local testing, it seems to do resolve this issue so far as I can tell.

    Posts: 67 Topics: 20
    | Permalink

    Barry – you are a complete star! It works! This is going to help our workflow SO much! Thank you!

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    Pleased to hear it — and thank you for bearing with us while we looked into this 🙂

    | Permalink