Home › Forums › Calendar Products › Events Calendar PRO › Custom AJAX call
- This topic has 5 replies, 2 voices, and was last updated 8 years, 7 months ago by George.
-
AuthorPosts
-
September 10, 2015 at 5:25 pm #1004021JohnParticipant
I was looking into pulling more events in with the mini-calendar but it doesn’t look like there’s an option to pull more than 5. In an effort to extend the list, I was thinking it may be possible to make an ajax call to do so.
Are there any hooks that would work best for this?
Thanks!
September 10, 2015 at 7:12 pm #1004052GeorgeParticipantHey David,
There is indeed not a simple option, or even a filter at this point, that would let you do this 🙁
Making an AJAX call to change the amount of events pulled in is a bit tricky too, and quite a lot of extra work – the simplest method I can think of for upping the amount of events queried for is to head into core plugin code itself. This is not recommended, and would require re-updating after every time you update the plugin until we add a filter for this, but for now you can do this by heading to your Events Calendar Pro plugin files and navigating to this file:
src/Tribe/Mini_Calendar_Widget.php
Once there, scroll to around line 35 or so until you see code like this:
$defaults = array(
'title' => __( 'Events Calendar', 'tribe-events-calendar-pro' ),
'count' => 5,
'filters' => null,
'operand' => 'OR',
);
Simply change the ‘count’ argument from 5 to whatever you’d like, save the changes, and that should work well here.
I’m really sorry that all this is required just to change that number! I agree that this is too complex, and will make a development ticket to make a filter for this that you can change it much more easily (and only have to do so once, and not update the code after every plugin update!).
— George
September 11, 2015 at 8:20 am #1004265JohnParticipantGeorge,
Thanks for the quick response. That works as a stand in but would really like to give users more control instead of dropping a whole month’s worth of events (20+) at one time.
So there is no way to get the next five events? I notice when changing to the next month an ajax call is made with the following headers:
action:tribe-mini-cal
eventDate:YYYY-MM-01
count:(whatever is set)
tax_query[0][taxonomy]:tribe_events_cat
tax_query[0][field]:id
tax_query[0][operator]:IN
tax_query[0][terms][]:category # set in shortcode
nonce: nonceIs there no way to use this call to get more events?
September 12, 2015 at 9:52 am #1004577GeorgeParticipantHey David,
I’m glad that my suggestion helped a bit. As for alternatives and more customizations here, I unfortunately cannot help with further custom coding – you may indeed be able to overwrite and customize this AJAX call and others, but that is relatively complex and outside the scope of our forum support 🙁
Please let me know if you have any other questions, comments, concerns, etc. – I will try to help as much as possible!
Thanks,
GeorgeSeptember 14, 2015 at 7:59 am #1004843JohnParticipantGeorge,
While fixed for now, the solution will be written over if the plugin is updated. This means I’ll have to advise the client they’re not to update the plugin.
It is a solution nevertheless, so thanks for your help.
September 14, 2015 at 5:46 pm #1005101GeorgeParticipantHey David,
I’m sorry about the extra headaches with having to work around your customizations here – we can definitely improve this functionality with filters or actions, for example, so stay tuned to plugin updates in the event that such improvements are included in an upcoming release.
Thanks for your feedback here, and for the kind words despite the limitations of our plugin!
Best of luck with your client project,
George -
AuthorPosts
- The topic ‘Custom AJAX call’ is closed to new replies.