Class | Ramaze::Pager |
In: |
lib/ramaze/helper/pager.rb
|
Parent: | Object |
Displays a collection of entitities in multiple pages.
This pager is carefully designed for scaleability. It stores only the items for one page. The key parameter is needed, multiple pagers can coexist in a single page. The pager leverages the SQL LIMIT option to optimize database interaction.
class MyController def index objs = (0..200).to_a @entries, @pager = paginate(objs, :limit => 20) end end <html> <head><title>Pager</title></head> <body> <?r if pager.navigation? ?> <div class="pager">#{@pager.navigation}</div> <?r end ?> <ul> <?r @entries.each do |entry| ?> <li>#{entry}</li> <?r end ?> </ul> </body> </html>
The following classes can be used for styling with CSS (provided you put the pager in a element with class ‘pager’ like shown above):
.pager {} .pager .first {} .pager .previous {} .pager .next {} .pager .last {} .pager ul {} .pager li {} .pager li.active {}
limit | [R] | Items per page. |
page | [R] | The current page. |
page_count | [R] | The total number of pages. |
total_count | [R] | Total count of items. |
request: | Ramaze::Request object providing access to GET parameters |
limit: | how many elements go to one page |
total_count: | total element count |
key: | key used for getting the current page from GET paramaters |
Note: You never have to create this class yourself, use the `paginate()` convenience method from the Helper::Pager.