Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

will_paginate multiple collections

#56

I recently faced an interesting problem. I wanted to use pagination on 2 different list items in the same page.

Right now, changing the page for 1 list would affect the second list of items (which I don't want).

I quickly hacked a patch to get many paginations working on the same page. I can certainly be refactored but anyway here is how one could use the new param passed to the will_paginate helper.

 <%= will_paginate @stories %>
<%= will_paginate @old_open_stories, {:page_param => 'old_stories_page'} %>

in the controller, one could access the :page param or the old_stories_page parameter.

Matt

Reported by Matt Aimonetti · July 16th, 2007 @ 01:44 AM

State: resolved
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Matt Aimonetti
    Matt Aimonetti
    • Title changed from [enhancement][patch] will_paginate paginate multiple list in same page to [enhancement][patch] will_paginate paginate multiple lists in the same page

    July 16th, 2007 @ 01:44 AM

  2. Mislav
    Mislav
    • Title changed from [enhancement][patch] will_paginate paginate multiple lists in the same page to will_paginate multiple collections
    • State changed from new to open

    This has been on my roadmap for quite some time. I will make it happen!

    July 16th, 2007 @ 01:44 AM

  3. Charles Brian Quinn
    Charles Brian Quinn

    Nicely done. I started whipping this up and came here to make sure no one had already done it.

    I noticed the patch misses the next and previous links:

            # next and previous buttons
            links.unshift page_link_or_span(entries.previous_page, 'disabled', options.delete(:prev_label), options[:page_param])
            links.push    page_link_or_span(entries.next_page,     'disabled', options.delete(:next_label), options[:page_param])
    

    also patch didn't apply clean on latest (line break issues maybe)?

    possible refactor could pass on options to the link_helper. Sorry, no tests either, I'm guessing an:

    assert_select to verify the correct custom page_param is in the a href links would work.

    Mislav, let me know if you want help or want to just pass off to me.

    July 16th, 2007 @ 01:44 AM

  4. Charles Brian Quinn
    Charles Brian Quinn

    OK,

    i patched and added tests, too.

    here's the pastie:

    http://pastie.textmate.org/76747

    enjoy!

    July 16th, 2007 @ 01:44 AM

  5. Matt Aimonetti (mattetti)
    Matt Aimonetti (mattetti)

    Mislav, any news about this new feature implementation?

    July 16th, 2007 @ 01:44 AM

  6. Mislav
    Mislav

    Matt,

    I will commit as soon as I find time. I've decided to throw in more magic than simply apply the patch from Quinn (BTW, thanks man!)

    July 16th, 2007 @ 01:44 AM

  7. Chris Wanstrath
    Chris Wanstrath
    • State changed from open to resolved

    (from [300]) WillPaginate: add :param_name option to enable overriding the page parameter name when calling the will_paginate helper. Of course, this defaults to "page" like before. Also add test_will_paginate_preserves_parameters to prove that #65 is invalid. [Matt Aimonetti, Charles Brian Quinn] [#56 state:resolved]

    http://require.errtheblog.com/pl...

    July 16th, 2007 @ 01:44 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.