SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Paged results

  1. #1
    SitePoint Zealot Packetloss's Avatar
    Join Date
    Aug 2003
    Location
    Behind You
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Paged results

    Hi,

    I'm using pagination to create paged results and so far I've got Previous and Next page links going like so:

    Code:
    recipe_controller.rb
     
     def list
     		@category = @params['category']
     		@recipe_pages, @recipes = paginate :recipes, :per_page => 2
     	end
    Code:
    list.rhtml
     
     <%= link_to 'Previous page', { :page => @recipe_pages.current.previous } if @recipe_pages.current.previous %>
     <%= link_to 'Next page', { :page => @recipe_pages.current.next } if @recipe_pages.current.next %>
    How could I make it so it would return the number of pages with links to each page, like how a forum would do it?

    Thanks
    My links: [ Blog ] - [ deviantArt ]

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <%= pagination_links @recipe_pages %>

  3. #3
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •