Non-AJAX Previous Events / Next Events Links

Home Forums Calendar Products Events Calendar PRO Non-AJAX Previous Events / Next Events Links

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #169319
    Marty
    Participant

    I have been working on updating a site from the 2.x to 3.x versions of the plugin. One thing I’ve encountered is the change in the way the the previous/next pagination links are constructed. Whereas before they were something like “/past/page/2/”, now they’re “/upcoming/?action=tribe_list&tribe_paged=2”.

    The default ECP theme uses AJAX to load the new page of posts. I don’t want to bother with AJAX, however. I just want to output a link to “?action=tribe_list&tribe_paged=3” or similar.

    Do you have any example code for nav.php which outputs this string?

    Thanks!

    #170831
    Barry
    Member

    Hi!

    I’m afraid we don’t have any example code for that – but you could certainly make use of these filters to change things:

    • tribe_get_past_link
    • tribe_get_upcoming_link

    Or, if you prefer a different approach, you could customize and remove the existing nav links via a template override – taking list view as an example, that might mean setting up a custom list/nav.php and adding your own custom code in there to form the links.

    Sorry we can’t offer much more on this one, but do check out the Themer’s Guide if you haven’t already done so for an overview of the basics when theming The Events Calendar 🙂

    #170865
    Marty
    Participant

    Thanks for your response. Can you help me get a bit further?

    As-is, the tribe_get_past_link() and tribe_get_upcoming_link() functions aren’t doing the full job of providing back/next links, since they don’t include the “?action=tribe_list&tribe_paged=3” string.

    In order to write alternatives to those functions, where would I get the variable to use with “paged=”?

    Thanks!

    #171869
    Barry
    Member

    OK, so the existing logic is contained exclusively in our Javascript (in the case of list view, that means tribe-events-ajax-list.js) and you can certainly refer to that to see how things are currently handled – but really to do what you need you’re going to have to create a PHP implementation and I’m afraid we can’t write that for you.

    Here’s an example though outlining the basics of setting up a filter for the next link:

    add_filter( 'tribe_get_upcoming_link', 'my_custom_next_events_link' );
    
    function my_custom_next_events_link( $base_link ) {
        $page = 1; // Expand this with your own logic, of course
        return add_query_arg( 'tribe_paged', $page, $base_link );
    }

    In terms of figuring out what the current page is you would need to inspect the URL query for the current request:

    $current_page = isset( $_GET['tribe_paged'] ) ? absint( $_GET['tribe_paged'] ) : 1;

    There isn’t too much more help we can provide for a customization like this one I’m afraid (and so I’ll go ahead and close this thread), but I hope that helps and at least gives you a basic outline you can build upon 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Non-AJAX Previous Events / Next Events Links’ is closed to new replies.