In the view, maybe something like:

{{import string}}
{{for browse_type in ['category', 'listing', 'locality', 'brand']:}}
{{=CAT('Browse by ', browse_type, ' ',
      *[A(letter, _href=URL('default', 'browse', args=[browse_type, 
letter]))
        for letter in string.uppercase])}}
{{pass}}

That will generate a set of links like /yourapp/default/browse/category/A, 
etc. Of course, you'll have to fill out the HTML a little more to get the 
exact format/layout you want -- the above is just an example of how to 
generate the links.

Then in the controller:

def browse():
    if len(request.args) < 2:
        redirect(URL('default', 'somewhere'))
    [code to generate items to browse based on browse type and letter]

Note, request.args(0) will contain the browse type (i.e., "category", 
"listing", etc.), and request.args(1) will contain the letter (i.e., "A", 
"B", etc.). You can use those values to generate the appropriate query, 
which will depend on how you have structured your data.

If some of the letters won't have any items, you might consider removing 
those links or making them inactive. This will require a database query 
before generating the pagination links so you know which links to show/make 
active -- to minimize db hits, you should probably cache that query for 
some time (or better yet, cache the complete pagination HTML).

Anthony

On Sunday, March 4, 2012 2:03:03 AM UTC-5, Praveen Bhat wrote:
>
> Hello,
>
> I have a Listings page for Businesses and I want a Alphabetical 
> pagination/menu like in the attached screenshot.
>
> Any help will be appreciated.
>
>
> Regards
> Praveen
>

Reply via email to