wpart_paginate

wpart_paginate makes the possibility of chunking the big collection of items into smaller parts and access them sequentially in the view.

Usage

The wpart:paginate tag has several meanings, depending on its attributes' values:

Displaying a page (part) of the collection

attribute

value

description

action

page

chunking the list into pieces and gives access to its small part

list

some_key

paginates the list held under given key inside request dictionary (it must be manually set in the controller)

as

some_key

saves the part of list we are interested in under the given key, so it is possible to fetch the contents of the list inside the wpart:paginate tag

per_page

some_number

defines the maximum length of the chunk (list) we pass to the inside of the tag. By default set to 10

attribute

value

description

action

next_link | prev_link

expands to the link to the next/previous part of the list

text

some_text

defines the text which should be displayed as the clickable link. By default set to "Next page" | "Previous page"

attribute

value

description

action

numbered_links

expands to the list of the links to the particular collection pages

list

some_key

generates the list of links for the list held under given key inside request dictionary (it must be manually set in the controller)

per_page

some_number

defines the maximum length of the chunk (list) we pass to the inside of the tag. By default set to 10

trim

some_number

trims (if needed) the list around the current page number. Useful when a list is very long (has a lot of pages). By default it is disabled

Example

controller.erl

  ...
  search(Keyword) ->
      ...
      wpart:fset("search_results", Results),
      {template, "templates/search.html"}.
  ...

search.html

   ...
       <wpart:paginate action="page" as="search_results_part"
           list="search_results" per_page="10">
           <ul>
               <wpart:list select="map" as="item" list="search_results_part">
               <li><wpart:lookup key="item" /></li>
               </wpart:list>
           </ul>
       </wpart:paginate>
       <wpart:paginate action="prev_link" text="Previous page" /> ||
       <wpart:paginate action="next_link" text="Next page" />

       or
       <wpart:paginate action="numbered_links" list="search_results" per_page="10" trim="3" />
   ...

Wparts/WpartPaginate (last edited 2009-04-20 09:23:55 by Michal Ptaszek)