Pagination is plugin for Movable Type that enables you to paginate lists of entries. For example, at the bottom of your home page, you could add a "Next" link so your readers can go to "Page 2" and read previous entries. You can display a list of linked page numbers to enable visitors to jump to any page number they want.
With Pagination Pro, you can also paginate your Category, Author, and date-based archives, and even paginate your Entry archives, displaying only a small number of comments on each page.
Try it Now - Live Demo
The MT4 Test Blog has the Pagination Pro plugin enabled. Scroll to the bottom of the home page to see the list of pages and follow the links. Also take a look at an example of a paginated Category archive here. Finally, take a look at a paginated version of a 300+ comment entry here.
How it Works
My goal here was to create a pagination plugin with high performance. I didn't want it to slow down rebuilds, and I wanted pages to display for readers without delay. With these goals in mind, I decided to dynamically render pages 2, 3, 4, and so on. This means that unlike the default for most pages in Movable Type, pages 2+ are not static files that get published to your blog directories. They dynamically rendered by the plugin's page viewer script. Note that this viewer script is Perl-based and does not use MT's built-in PHP-based dynamic publishing system. The benefit of this is that you can virtually any plugin template tags in your paginated templates, and you don't need to use PHP. So when someone views page 2, the script goes into action and builds the page and displays it.
Paginated URLs are clean, ending in index.html?page=2 (or similar). Pagination makes use of mod_rewrite for Apache to keep these URLs clean (most MT sites run on Apache, but there may be some alternative approaches for other web servers).
To speed up dynamic page views and reduce CPU/memory/database usage, Pagination supports (optional) page-level caching, powered by the Cache Block plugin. This means that once the plugins generates the HTML for "page 2", it will store that in the cache for next time. And next time someone wants to see "page 2", it can be quickly fetched from the cache. In my tests, dynamic page views from the cache took about 0.04 seconds, so this is very fast. In the plugin settings you can specify how long to cache pages before refreshing the cache.
Pagination comes with a template module that makes it easy to implement -- in most cases you can simply include the module in your existing templates and it will 'just work'. So you may not need to learn or use the template tags below. But if you want to customize the appearance of your Pagniation links, you can use/edit the following tags:
- <mt:PaginationPages> - This is a container tag for displaying linked page numbers, previous / next page links, etc. This tag should only be placed inside the following containers: <mt:EntriesFooter>, <mt:EntriesHeader>, <mt:CommentsFooter>, and <mt:CommentsHeader>. There are several arguments:
- max_pages - (Required) The maximum number of page numbers to display at one time. Note that page numbers will roll forward as readers view higher page numbers, just like Google paginated search results.
- glue - (Optional) This should contain some text or symbols that you to display bewteen each page number. For example, if you want 1 - 2 - 3, then use glue=" - ".
- lastn - (Required) The number of items shown on each page. This must match the lastn argument of the parent <mt:Entries> or <mt:PaginatedComments> tag.
- archive_type - (Optional) For advanced use, you can use this tag to override the archive_type used to calculate the page numbers and links. If omitted, the plugin will use the archive_type of the page being built.
- class_type - (Optional) For advanced use, this tag will override the type of MT object being counted to determine the number of pages.
- <mt:PaginationPageNumber> - Used inside a <mt:PaginationPages> container, this tag will display the page number being processed in the loop (not the current page number that is being published/viewed).
- <mt:PaginationPageLink> - Used inside a <mt:PaginationPages> container, this tag will display the URL to page number being processed in the loop.
- <mt:IfPreviousPage> - Conditional tag that is true if the page being displayed is 2 or higher.
- <mt:PaginationPreviousPageLink> - The URL to the previous page.
- <mt:IfNextPage> - Conditional tag that is true if the currently viewed page is not the last page.
- <mt:IfNotLastPage> - Conditional tag that is relative to the page being processed, not the page being viewed - returns true if the page being processed is not the final page.
- <mt:LastPageLink> - The URL to the last page.
- <mt:LastPageNumber> - The number of the last page.
- <mt:PaginatedComments> - (Pro only) This is replacement container tag for <mt:Comments>. If you want to paginate the list of comments on an Entry archive, you should use <mt:PaginatedComments> instead of <mt:Comments>. You can use all the same <mt:Comment_____> tags inside the container. Arguments include:
- show - The number of comments to show per page. (Note that you can also use 'lastn' for this argument)
- offset - The offset for the page of comments. This should always be set to "$pagination_offset".
Pagination comes with two templates:
- Pagination - A template module that can be included in other templates to display page links.
- HTACCESS for Pagination - An index template that builds the required mod_rewrite rules. Important: The output file for this template has been set to "htaccess.txt" on purpose. Some sites have already have a ".htaccess" file and you want to be careful not to overwrite the existing one (for example, if you use MT's PHP dynamic publishing, with my Fast Search plugin or otherwise). Check to see if you already have an .htaccess file and if you do, you may want build this template as "htaccess.txt" and then copy and paste the rules into the appropriate place in your .htaccess file (if using MT's dynamic publishing, paste before the existing rules.) If you want to use this template to build your .htaccess file, you will need to change the output file to ".htaccess".
Note: while not required, the Cache Block plugin is needed if you want to use the Pagination caching features.
- Download the zip file and upload the contents of the 'plugins' folder to the 'plugins' directory of your MT installation.
- Change the permissions of the /plugins/Pagination/pages.cgi script to 755 (CHMOD 755).
- Go to the blog you want and then to Preferences > Plugins and then open the settings for the Pagination plugin. Enable the caching settings if desired, then Save.
- Return to the settings and click the "Install Templates" button. This will install the templates mentioned above.
- Setup your .htaccess file with the Pagination rules, as described above.
- Edit your Main Index template and add the following before the </MTEntries> tag:
- Modify your <MTEntries tag to include the argument offset="$pagination_offset". This is important. Example: <MTEntries lastn="10" offset="$pagination_offset">
- (Pro only) Do the same for your "Entry Listing" archive template, for both MTEntries containers.
- (Pro only) If you want to paginate your comment listings on your Entry archives, edit the "Comments" template module to replace the <MTComments> container with the MTPaginatedComments container, as discussed above. Be sure to include show="10 offset="$pagination_offset".
Get Pagination Pro
Commercial License for 1 to 10 blogs - $97
Blog Network License for 10+ blogs - $249
Personal License for 1 to 4 blogs - $33
Pagination is free for personal or commercial use, but you must leave the "powered by" link, which is added automatically below the paginations links.
,<$MTAjaxRatingVoteCount type="paginationdownloads" id="1"$>,0);">
Downloads: <$MTAjaxRatingVoteCount id="1" type="paginationdownloads"$>
As always, comments, questions, and suggestions are welcome.