tips and tricks for movable type

paginated dynamic index page with smarty
November 06, 2004

Brad gave me this Smarty code for paginating an index page (i.e., where you can have previous/next links with a certain number of entries per page).

Above the primary <MTEntries> container in your page, use something like this:

<p align="right">
{{if $smarty.request.start > 0}}
<a href="?start={{$smarty.request.start-5}}">Previous</a>
{{/if}}

<MTEntries lastn="1" offset="`$smarty.request.start+5`">
{{if $smarty.request.start > 0}} | {{/if}}
<a href="?start={{$smarty.request.start+5}}">Next</a>
</MTEntries>
</p>

and then modify the primary <MTEntries> tag to look like this:

<MTEntries lastn="5" offset="`$smarty.request.start`">

You can change 5 to the number of entries you want per page.

I really need to learn more about Smarty. Brad says there are a lot of neat things you can do with it, and Lord knows I haven't spent much time lately just doing "neat things". :p

(Which means don't bother asking me too many questions about this. I have no idea how the hell it works - I'm just documenting the code before I forget about it.)

Comments

For this to work, I believe you also need lastn="5" in your <MTEntries>.

by Tom Vamvanij [TypeKey Profile Page] | 01.17.05 09:42 PM

Has anyone else had any trouble getting this to work? I'm trying to get it working on my blog which publishes dynamically, but I haven't had any luck. The next link appears, but it doesn't move forward when clicked:
http://booizzy.com/archives/cat_technology_stuff.php

If anyone has any ideas, I'd really appreciate it.

by Boo & Izzy [TypeKey Profile Page] | 03.18.05 07:02 PM

Hi girlie,

I have installed mt 3.2 with dynamic template.
I have installed your instructions in category template and I got two problems:

1) It shows me all posts (13 posts), instead only the firts five;

2) If i do next I got the following error:
SQL/DB Error -- [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'offset 5' at line 17]
Since I am not a pc programmer, could you help me to understand where I am wrong?
Thank you

raffaele
Italy

by raffaele | 01.06.06 07:21 AM

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

TrackBack: 4
(URL: http://www.thegirliematters.com/sf/mt-track.cgi/209)

» Pagination
Excerpt: [the girlie matters] tips and tricks: paginated dynamic index page with smarty Pretty neato feature. I realize more and more everyday that I barely know what the hell I'm using anymore....
Weblog: achtungbaby's tribulations
Tracked: 11.06.04 08:55 PM

» paginated dynamic index page with smarty
Excerpt: [the girlie matters] tips and tricks for movable type...
Weblog: 메디짱의 세상 바라보기
Tracked: 12.05.04 06:30 AM

» go go gadget paginate
Excerpt: There's something to be said for a website that's not so completely overwhelming on a slow internet connection. With this in mind, I set out to find a better way to list my archived pages. Previously, when a Monthly or Category archive page was visited...
Weblog: imatt.us
Tracked: 01.26.05 12:51 PM

» links for 2005-03-08
Excerpt: [the girlie matters] tips and tricks: paginated dynamic index page with smarty (categories: movabletype) Jybe! - CoSurfing re-invented (categories: software web) Learning To Love You More (categories: crafty) frontline: the soldier's heart | PBS (cate...
Weblog: BooIzzy.com
Tracked: 03.08.05 12:21 PM