Pagination google style
Using pagination for your article lists is made simple thanks to the ob1_googlenav plugin.
Textpattern comes with its own pagination tags – newer and older – while these tags work just fine, the goal here is to create a Google style navigation list.
- First, download the plugin and install in the usual way.
Once the plugin is activated, we can place some code in our page template.
Call the plugin from your page
<txp:if_section name="articles">
<txp:article form="article_list" limit="20" />
<txp:ob1_pagination firsttext="First page" previoustext="Previous page" nexttext="Next page" lasttext="Last page" ulclass="pagination" liselected="active" />
</txp:if_section>
The above code is placed in your page template, after the txp:article call. What this does is create a pagination link after the first 20 articles.
Note: In the plugin help file there is an error in the example, which uses the old ob1_googlenav tag. This needs to be ob1_pagination as in my example above.
The plugin attributes are self-explanatory, and documented in the plugin help file.
Some CSS to style the pagination links
ul.pagination {margin: 1em 0; padding: 0.5em; text-align: center; background: #eee;}
ul.pagination li {display: inline; font-size: 0.625em; padding: 0.5em;}
ul.pagination li.active {background: #fff; border: 1px solid #eee;}
Use similar styles to achieve the effect you want.
Thanks to Craig Valadez of struc1.com for suggesting this tip.
9 Comments - Comments RSS Feed
Niklas
# 1 April 2009
Hi. I’m a bit of a beginner here… How do you make this section sensitive. In my implementation pagination links point to the main template. Easy olutions? Or am I just using the code in a wrong manner?
Niklas
# 3 April 2009
Oh. I use <txp: if_section name”“ and now I found the reason why it’s not working. I use <base href=“http://mysite.com/” /> to find the right paths to site’s visual elements (pics). If I remove that… well, the pictures don’t show in the right way. Is there anything I can do about that. Making absolute urls to all pictures doesn’t really seem an option. Huh.
BTW. Thanks again for your help and great plugin!
Niklas
# 3 April 2009
Hmmm… I use relative path <img src=“images/myimage.gif” /> in my image links. However, for some reason without base href tag or absolute urls images aren’t displayed in the other sections on my site. I’ve scanned for possible solutions to the problem… without all-encompassing results.
Mark
# 22 April 2009
Ive been having problems with this and found this page whilst trying to resolve it.
Even copying your code into my section exactly as it is, only modifying my article form name and section name, it outputs nothing. Zero. Zilch.
Any suggestions would be phenomenally helpful!
Forum thread with details:
http://forum.textpattern.com/viewtopic.php?id=30513

Matt
# 7 February 2009
Awesome plugin. Really easy to use and very configurable.