Hello everybody ! Well... I've been searching for a good way to paginate my search results. I've found that the best way is to use the paginate decorator : http://docs.turbogears.org/1.0/PaginateDecorator However, presenting the navigation isn't that easy.
I've found some css tutorial to do that : http://blog.tafticht.com/2007/10/01/tutorial-de-creation-dune-barre-de-pagination-tout-en-css-avec-15-exemples/ To help people who will want to do the same in the future, here is a snippet to generate needed xhtml. First set up the paginate decorator as show on the wiki page. Then, include this in an extended template (a function) : <span py:def="display_page_link(page)"> <a py:if="page != tg.paginate.current_page" py:attrs="href=tg.paginate.get_href(page)" py:content="page"></a> <span class="current" py:if="page == tg.paginate.current_page" py:content="page"></span> </span> <p py:def="paginate_nav()" id="pagination"> <span class="disabled" py:if="tg.paginate.page_count > 2 and not tg.paginate.href_prev">◄ Précédent</span> <a py:if="tg.paginate.page_count > 2 and tg.paginate.href_prev" py:attrs="href=tg.paginate.href_prev">◄ Précédent</a> <span py:if="tg.paginate.page_count < 6" py:for="page in tg.paginate.pages"> ${display_page_link(page)} </span> <span py:if="tg.paginate.page_count >= 6"> <span py:if="tg.paginate.current_page < 4"> <span py:if="tg.paginate.current_page < 3" py:for="page in tg.paginate.pages[:3]"> ${display_page_link(page)} </span> <span py:if="tg.paginate.current_page >= 3" py:for="page in tg.paginate.pages[:tg.paginate.current_page+1]"> ${display_page_link(page)} </span> ... ${display_page_link(tg.paginate.page_count)} </span> <span py:if="tg.paginate.current_page >= 4 and tg.paginate.current_page <= (tg.paginate.page_count - 3)"> ${display_page_link(1)} ... <span py:for="page in tg.paginate.pages"> ${display_page_link(page)} </span> ... ${display_page_link(tg.paginate.page_count)} </span> <span py:if="tg.paginate.current_page > (tg.paginate.page_count - 3)"> ${display_page_link(1)} ... <span py:for="page in tg.paginate.pages[-4:]"> ${display_page_link(page)} </span> </span> </span> <span class="disabled" py:if="tg.paginate.page_count > 2 and not tg.paginate.href_next">Suivant ►</span> <a py:if="tg.paginate.page_count > 2 and tg.paginate.href_next" py:attrs="href=tg.paginate.href_next">Suivant ►</a> </p> Last, in your paginated template, where you want to see the nav : ${paginate_nav()} Hope it helps :) Cheers, Jon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

