Home › Forums › Calendar Products › Events Calendar PRO › Non-AJAX navigation for List view
- This topic has 8 replies, 2 voices, and was last updated 8 years, 11 months ago by Matthew.
-
AuthorPosts
-
March 26, 2015 at 1:54 pm #951300MartyParticipant
Hi there,
Out-of-the-box, ECP uses JavaScript to power the Previous Events / Next Events links at the base of List view. For various reasons, the site I’m working on needs those to be regular, non-JS links.
Last time I tackled this was circa ECP 3.7, and I used tribe_get_past_link() and tribe_get_upcoming_link() as a base, appending “paged” variable and such to get the desired links. Like so:
https://gist.github.com/halfempty/a99abf2c883d88333380
Now I’m updating to 3.9.1 and the behavior of those two functions has changed. Before I go down the rabbit hole of rewriting my functions, are there any functions already in core that will do this job?
Thanks!
March 26, 2015 at 3:33 pm #951323MatthewMemberHowdy Marty – that’s a solid question!
Disabling Ajax-driven paging on the month and the day view works swimmingly with this tip. But, as you’re experience has shown you, non-Ajax pagination on the list view doesn’t work so well. The good news is, your code looks pretty good and with a few tweaks I think we may be able to find a solution that should work. Can you try a few tweaks for me and let me know how they go?
First, make sure this is in your functions.php file:
/** * Remove Ajax from The Events Calendar Pagination on List View * @3.8 * */ add_action('wp_print_scripts', 'events_calendar_remove_scripts' , 10); function events_calendar_remove_scripts() { wp_dequeue_script( 'tribe-events-list'); }
Next, try tweaking your spellerberg_* functions to make use of the tribe_get_listview_link() in place of any of the calls to tribe_get_past_link() and tribe_get_upcoming_link(). That function returns the List view URL used by the List view JS to build the previous/next Ajax requests. My quick test of your functions with that change gave me some promising results!
Does that help point you in the right direction?
April 4, 2015 at 7:31 pm #953302MartyParticipanttribe_get_listview_link() returns:
/events/category/mycategory/list/
In order to construct the URLs, it looks like the bast I need is:
/events/category/mycategory/
Is there a method that will output that?
April 6, 2015 at 6:26 am #953409MatthewMemberThe events_get_events_link() function should return the events link sans
/list/
. Let me know if that works for you!April 6, 2015 at 12:30 pm #953513MartyParticipantClose, but not quite. It needs to have the current category slug in there, as applicable.
April 7, 2015 at 7:12 am #953692MatthewMemberWhoops – sorry about that! Fetching that link isn’t something that we have in The Events Calendar as a single functionc all. However, you can retrieve that link using WordPress’ get_term_link() function in conjunction with our tribe_is_event_category() and tribe_meta_event_category_name() functions. With something like this:
// default the link to the base events link $link = events_get_events_link(); // if you're on a category page, fetch the base link for it if ( tribe_is_event_category() ) { $link = get_term_link( tribe_meta_event_category_name(), 'tribe_events_cat' ); }
Perhaps a bit more than what you were hoping, but it should do what you are looking to accomplish. Let me know how it goes!
April 15, 2015 at 1:47 pm #955828MartyParticipantHi. Looks like we’re very close. One thing, though. This line:
`$link = get_term_link( tribe_meta_event_category_name(), ‘tribe_events_cat’ );’
get_term_link() wants either an object, ID or slug, but
tribe_meta_event_category_name() returns the category name.What will give us the ID or slug? Thanks!
April 16, 2015 at 11:49 am #956114MatthewMemberWell shoot, I guess I should have tested that code with a more realistic Event Category name. Sorry about that. Anyhow, give this approach that leverages $wq_query a shot:
global $wp_query; // default the link to the base events link $link = events_get_events_link(); // if you're on a category page, fetch the base link for it if ( tribe_is_event_category() && isset( $wp_query->query_vars['tribe_events_cat'] ) ) { $link = get_term_link( $wp_query->query_vars['tribe_events_cat'], 'tribe_events_cat' ); }
May 4, 2015 at 6:51 am #960197MatthewMemberIt has been a while since we’ve traded messages so I’ll go ahead and close this thread for now. If you run into any other issues – feel free to open another thread!
-
AuthorPosts
- The topic ‘Non-AJAX navigation for List view’ is closed to new replies.