Warning

This document hasn't been checked for compatibility with current versions of Plone. Use at your own risk.

PloneBatch: Advanced Usage

by Helge Tesdal last modified Dec 30, 2008 03:04 PM
The batch navigation is customizable, and here is an overview of the more advanced features available.

The Batch constructor takes these arguments:

sequence -- The list to batch

size -- The number of items in each batch

start=0 -- The first item in the batch, 0-index

end=0 -- The last item in the batch, 0-index and optional

orphan=0 -- The next page will be combined with the current page if it does not contain more than orphan elements. Optional and default 0

overlap=0 -- The number of overlapping elements in each batch. Optional and default 0

pagerange=7 -- The number of pages to display in the navigation menu

quantumleap=0 -- 0 or 1 to indicate wheter bigger increments should be used in the navigation list for big results. This would make navigation faster as you could make bigger jumps.

b_start_str='b_start' -- The variable name to be used to set the start of the batch. Changing this enables multiple batches with different starting points on the same page.


Making your own navigation menu

You can make your own navigation menu if you are not satisfied with the regular one. To do this you have to know which attributes are available in the batch object.

size -- Batchsize

start -- First element, 1 based index into the sequence

first -- First element, 0 based index into the sequence

end -- Last element, 0 based index into the sequence

orphan -- The next page will be combined with the current page if it does not contain more than orphan elements

overlap -- The number of overlapping elements in each batch

length -- Length of the batch

b_start_str -- The name of the request variable storing batch starting point

last -- First element on last page

previous -- previous Batch, previous.first is the first element in the previous page

next -- next Batch, next.first is the first element in the next page

sequence_length -- The length of the result

numpages -- Total number of pages

pagenumber -- Current page number

pagerange -- The computed number of pages to display in the navigation menu

pagerangestart -- The first page to display in the navigation menu

pagerangeend -- The last page to display in the navigation menu

navlist -- A list containing the pagenumbers for the navigation list

prevlist -- A list containing the pagenumbers for the navigation list with pagenumbers lower than the current page

nextlist -- A list containing the pagenumbers for the navigation list with pagenumbers higher than the current page

quantumleap -- 0 or 1 to indicate if there should be bigger gaps between the pagenumbers in on the edges of the navigation list

leapback -- A list containing the pagenumbers for the quantum leap navigation list with pagehumbers lower than the current page

leapforward -- A list containing the pagenumbers for the quantum leap navigation list with pagehumbers lower than the current page

pageurl(self, formvariables, pagenumber=-1): -- """ Makes the url for a given page """

def navurls(self, formvariables, navlist=[]): -- """ Returns the page number and url for the navigation quick links """

def prevurls(self, formvariables): -- """ Helper method to get prev navigation list from templates """

def nexturls(self, formvariables): -- """ Helper method to get next navigation list from templates """


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.