#170 ✓resolved
Zohar Arad

Pagination links in list mode

Reported by Zohar Arad | December 16th, 2007 @ 09:41 PM

Hey there

I've just downloaded and installed the will_paginate plugin, which

works great on my blog app. and I'd like to thank you for creating it :)

I wanted to extend the functionality of the plugin to support a

rendering mode with an unordered list rather than a DIV with spans /

links inside it, as some XHTML developers like to render a list of

links that way.

My fix adds the option to pass :list_mode => true as a parameter to

the will_pagination plugin, which will render the pagination as an

unordered list. The default value of this parameter is :list_mode =>

false so that it behaves as before if not told otherwise.

Additionally, I added an optional :id parameter, which will add an "id" attribute to the pagination wrapping element (whether UL or DIV) for easier targeting via JavaScript.

I hope that you consider updating the plugin to support the above, or

grant me permission to upload it to my webspace with this amendment.

Comments and changes to this ticket

  • Mislav

    Mislav December 19th, 2007 @ 03:24 PM

    • State changed from “new” to “open”
    • Title changed from “will_paginate enhancement” to “list mode enhancement”

    Hi, thanks for the suggestion/patch!

    I've been planing to make a list mode for some time now, your code might help me to do it faster :)

  • Zohar Arad

    Zohar Arad December 19th, 2007 @ 10:28 PM

    Hey

    Hope my code helps :)

    Please let me know if there's anything else I can do regarding this.

    Regards

    Zohar

  • Mislav

    Mislav December 25th, 2007 @ 04:32 AM

    • Title changed from “list mode enhancement” to “[idea] list mode”
    • Assigned user changed from “Chris Wanstrath” to “Mislav”
  • omarqureshi

    omarqureshi July 3rd, 2008 @ 01:36 PM

    • Tag set to will_paginate

    Sounds like a good idea, would definately be up for this patch

  • Mislav

    Mislav October 13th, 2008 @ 02:47 AM

    • Title changed from “[idea] list mode” to “Pagination links in list mode”
    • State changed from “open” to “resolved”
    • Tag changed from will_paginate to html, will_paginate

    I've given this a lot of thought and resolved not to support list mode in core. I just don't see the semantic advantage, particularly when considering an unordered list.

    Here is a drop-in link renderer that can do what you wanted. (This works on the "agnostic" branch of will_paginate, soon to be released.)

    
    class ListRenderer < WillPaginate::ViewHelpers::LinkRenderer
    
      def to_html
        html = pagination.map do |item|
          item_html = item.is_a?(Fixnum) ? page_number(item) : send(item)
          tag(:li, item_html)
        end.join(@options[:separator])
    
        @options[:container] ? html_container(html) : html
      end
    
      def html_container(html)
        tag(:ol, html, container_attributes)
      end
    
    end
    

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Everyone's favorite Ruby library for pagination of practically anything!

People watching this ticket

Attachments

Pages