WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
Broken em_events_output_pagination filter? (22 posts)

  1. jbx
    Member
    Posted 11 months ago #

    I have just noticed that the event list/archive pagination is not working any more on my site. It was working for the past few months (I had posted this here: http://wordpress.org/support/topic/pagination-styling?replies=5) and I have not touched anything since then.

    There were some updates to this plugin which I installed, so I don't know at which point this broke.

    Were there any changes done to the em_events_output_pagination filter lately? It is being invoked but something seems to have changed to the arguments because it seems I am not getting anything in the $link template (the second parameter), or something unexpected is being passed to it.

    My event hook function looks like this:

    function my_em_paginate($links, $link, $total, $limit, $page=1, $pagesToShow=10)
    {
       //my code
       return apply_filters('em_paginate', $string);
    }
    
    add_filter('em_events_output_pagination','my_em_paginate', 1, 6);

    http://wordpress.org/plugins/events-manager/

  2. angelo
    NetWebLogic Support
    Posted 11 months ago #

    hi,

    using pastebin.com can you share your whole snippet?

  3. jbx
    Member
    Posted 10 months ago #

    Sure, here it is:

    http://pastebin.com/AUxjPkiB

    The Previous and Next are appearing as they should, however their HREF links are ending up completely empty.

  4. angelo
    NetWebLogic Support
    Posted 10 months ago #

    I tried your snippet and seems to work? can I know what's happening on your site?

  5. jbx
    Member
    Posted 10 months ago #

    I also have my own event-list.php under my own theme in plugins/events-manager/templates

    Maybe something changed in the functions used by that then?

    Code here: http://pastebin.com/kseiFXDg

  6. angelo
    NetWebLogic Support
    Posted 10 months ago #

    I see, maybe your custom event-list.php template needs updating also. but can I also know what's happening on your site since it's abit unclear.

    thanks

  7. jbx
    Member
    Posted 10 months ago #

    You mean you want to see the site URL?
    This is the link: http://www.eve.com.mt/events

    As you can see if you do 'View Source' the NEXT link just has an empty HREF.

  8. philipjohn
    Member
    Posted 10 months ago #

    Hiya,

    First thing to do here really is to temporarily remove your customisations and see if pagination works. If it does, we know to focus on your modifications.

    Could you try that please and let us know what the outcome is?

    Thanks,
    Phil

  9. jbx
    Member
    Posted 10 months ago #

    Hi philipjohn,

    So, I temporarily removed the custom event-list.php, so that it uses the default ugly list of events. The next link still didn't have any HREF.

    I then temporarily commented out the filter I pasted earler here: http://pastebin.com/AUxjPkiB

    The ugly 1 2 3 > links appeared and their page links were fine. So I guess one of the latest updates had some change which broke this in some way? Even though angelo_nwl said he tried my snippet and it worked for him.

  10. angelo
    NetWebLogic Support
    Posted 10 months ago #

    here's another thing you can try; using default pagination you can hook into em_paginate then use css/php to modify the pagination

    if you use the em_paginate filter, you could just wrap the contents in a div, eg.

    function my_em_paginage($content){
      return "<div>$content</div>";
    }
    add_filter('em_paginate','my_em_paginate',1,1);
  11. jbx
    Member
    Posted 10 months ago #

    Hi angelo_nwl,

    I don't want the default pagination. The client just wants NEXT and PREV with some surrounding wrapper elements for styling them one to the left and one to the right and putting the respective images around them. Its not as simple.

  12. jbx
    Member
    Posted 10 months ago #

    OK, so I put some echo lines in my pagination hook function and I found that since one of the recent versions, the second parameter which should be the $link template is completely empty. This used to have the link with the PAGE parameter.

    Did the order of parameters change or something?

  13. jbx
    Member
    Posted 10 months ago #

    Hi,

    I compared events-manager/classes/em-events.php of the latest version with the newest version, and I think the bug is in this line, in functions output() and output_grouped().

    $output .= apply_filters('em_events_output_pagination', self::get_pagination_links($args, $events_count, 'search_events_grouped', self::get_default_search()), '', $events_count, $args['limit'], $args['page']);

    The $link_template parameter passed to the filter is explicitly being set to '', no wonder I am getting an empty string.

    In the old version when it worked it used to be:

    $page_link_template = preg_replace('/(&|\?)pno=\d+/i','',$_SERVER['REQUEST_URI']);
    $page_link_template = em_add_get_params($page_link_template, array('pno'=>'%PAGE%'), false); //don't html encode, so em_paginate does its thing;
    
    $output .= apply_filters('em_events_output_pagination', em_paginate( $page_link_template, $events_count, $limit, $page), $page_link_template, $events_count, $limit, $page);

    The $page_link_template was explicitly being set. Now it disappeared.

    Can you schedule a fix to bring this back to work properly?

  14. jbx
    Member
    Posted 10 months ago #

    I fixed it by changing the output line to the following in events-manager/classes/em-events.php:

    $page_link_template = preg_replace('/(&|\?)pno=\d+/i','',$_SERVER['REQUEST_URI']);
    $page_link_template = em_add_get_params($page_link_template, array('pno'=>'%PAGE%'), false); //don't html encode, so em_paginate does its thing;
    
    $output .= apply_filters('em_events_output_pagination', self::get_pagination_links($args, $events_count, 'search_events', self::get_default_search()), $page_link_template, $events_count, $limit, $page);

    However, it will be lost the moment I update to a newer Events Manager version. Can it be included in the next version before a new update is issued?

    thanks

  15. philipjohn
    Member
    Posted 10 months ago #

    Hiya,

    I do get the issue when trying your snippet so I will pass this along to Marcus for a fix.

    Thanks!

  16. jbx
    Member
    Posted 10 months ago #

    Cheers! I think there are a couple of more places where the filter is being invoked, so might be a good idea to check them out.

  17. jbx
    Member
    Posted 10 months ago #

    Any idea if this fix was incorporated in version 5.5.1 just released? I don't want to update and lose this fix.

  18. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 10 months ago #

    sorry about that, we've restructured the way pagination is generated so that it's more consistent across different objects (categories, locations etc. used duplicate code before) and that variable in the filter was changed to be blank.

    the problem is $page_link_template gets generated in that new central function we created. I think what you want to do here is either rewrite your function or maybe make use of another filter.

    I haven't added a filter to EM_Object::get_pagination_links(), maybe putting one there will help?

  19. jbx
    Member
    Posted 10 months ago #

    Hi Marcus,

    The filter I am using at the moment was very convenient because it passes the number of pages, current page etc. all as separate arguments.

    The other hook (at least the one I know of) just receives the string with the page links. My page links are substantially different and I don't want to hack around with some messy solution of trying to parse the default link and extract the links from that, apart from the fact that it will be difficult to know whether there are more pages left to enable/disable the Next (or Prev) buttons.

    If you want to introduce a new filter that provides the same information (base link, number of pages, number of items, current page etc.) so that one could structure it as needed I guess it would be fine. However I don't really see why you should leave the old filter broken like that in the codebase honestly, especially when it was working fine up till a few versions ago. Isn't there any way to use the new centralised $page_link_template function correctly in the old filter in some way?

  20. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 10 months ago #

    there's a lot of redundant code the old way. there was a bug specifically revolving $page_link_template in fact and this meant we had to edit some 4 or so files with the same code and bug.

    I'll look into a workaround and get back to you.

  21. jbx
    Member
    Posted 10 months ago #

    Cheers, looking forward so that I can keep up to date to the latest version with your plugin.

    Thanks a million.

  22. angelo
    NetWebLogic Support
    Posted 8 months ago #

    Sorry for the delay in notifying you, but this should be fixed in 5.5.2, let us know if not and we'll have another look!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags