« Import FriendFeed Comments | Main | Dirify Old - Restore the Old Pre-4.2 dirify Function »

Pagination 1.5 - Create Multi-Page Entries

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. New in version 1.5: You can also paginate long entries by splitting them up into multiple pages.

New Features in Pagination 1.5

  • Support for MT 4.2 (minor bug fixes that may affect some sites running MT 4.2+)
  • New template tags for next / previous page numbers
  • Split long entries into multiple pages by easily inserting page breaks (Pro only)

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.

New: Paginated Entry Example - ReadWriteWeb

The latest version of the Pagination plugin is used by the popular technology blog ReadWriteWeb. (Disclosure: I provide consulting services to RWW) In additional, using Pagination to paginate the home page, category, and monthly archives, you can click here for an example of a long entry that has been split into 2 pages.

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).

Page-Level Caching

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.

Template Tags

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 . 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:NextPageNumber> - The number of the next page.
  • <mt:PreviousPageNumber> - The number of the previous 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".

Template Tags for Entry Pagination

A new feature in Pagination Pro enables you to split long entries into multiple pages by adding <!--nextpage--> (on a line by iteself) when writing the entry, in either the main "Body" or "Extended" fields. Then, using the following template tag modifer or tags, you display only the current "part" of the entry, along with pagination links. Note: in order to differentiate this type of pagination, the term "part" is used instead of "page" -- think of it as splitting an entry into multiple parts.

(Note that using <!--nextpage--> for page breaks is consistent with the built-in feature of Wordpress. This consistency may come in handy for sites migrating from WP to MT, as the existing page breaks should "just work".)

The easy way to use this feature is to use a new modifier called paginate on the tag that you want to split into parts for example:

<mt:EntryBody paginate="1">

or

<mt:EntryMore paginate="1"> (if your page breaks are added to the "Extended" field)

Simply add the paginate="1" argument to your existing tags in your Entry archives and MT will display only the relevant part of the field, along with pagination links at the bottom.

If you want more flexibility, instead of using the modifier described above, you can use the following template tags to control the display of the parts and page numbers:

  • <mt:PaginatedTag> - This container is designed to container the part(s) and page links for a paginated Entry Field. There is one required argument:
    • tag - The tag with the page breaks, without the "mt:" prefix. Valid values are 'EntryBody' and 'EntryMore'. Example: <mt:PaginatedTag tag="EntryBody">
  • <mt:CurrentPart> - This tag displays the current part of the tag (part 1 on page 1, part 2 on page 2, etc.). This tag must be used inside a <mt:PaginatedTag> container.
  • <mt:Parts> - This container tag list the pages and page links for each part, if page breaks exist in the specified tag. This tag must be used inside an <mt:PaginatedTag> container. There is one optional argument:
    • glue - the value of glue will act as a separator between each part number. Example: <mt:Parts glue=" | ">
  • <mt:PartNumber> - Displays the part number.
  • <mt:PartLink> - Displays the URL that links to page for the part.
  • <mt:IfPreviousPart> - Conditional tag that is true if the part being displayed is 2 or higher.
  • <mt:PreviousPartLink> - The URL to the previous part.
  • <mt:IfNextPart> - Conditional tag that is true if the currently viewed part is not the last part.
  • <mt:NextPartLink> - The URL to the next part.

Variables: For advanced usage, several variables are set by the plugin. A global variable called 'current_part_number' will be assigned to the value of currently displayed part on pages 2+, but remains undefined on page 1. Within an <mt:Parts> container, a local variable called 'current_part' is assigned to a value of 1 if the part being processed is the currently displayed part. Finally, standard loop variables such as __first__, __last__, etc. are assigned and can be used inside <mt:Parts>

Complete Example:

<mt:PaginatedTag tag="EntryMore">

<mt:CurrentPart>

<mt:Parts glue=" &nbsp;">
<mt:If name="__first__">
<div class="partination"><p><strong>Page: &nbsp;
<mt:IfPreviousPart>
<a href="<mt:PreviousPartLink>">&laquo;&nbsp; Prev</a>
</mt:IfPreviousPart>
</mt:If>
<mt:If name="current_part">
<mt:PartNumber>
<mt:Else>
<a href="<mt:PartURL>"><mt:PartNumber></a>
</mt:If>
<mt:If name="__last__">
<mt:IfNextPart>
<a href="<mt:NextPartLink>">&nbsp;Next &nbsp;&raquo;</a>
</mt:IfNextPart>
</strong></p></div>
</mt:If>
</mt:Parts>

</mt:PaginatedTag>

Note: the template tags above will only work on templates published using MT's default "static" publishing system. The tags will generate an error if used on dynamically published templates.

Templates Set

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".

Requirements

Note: while not required, the Cache Block plugin is needed if you want to use the Pagination caching features (highly recommended).

Installation

  1. Download the zip file and upload the contents of the 'plugins' folder to the 'plugins' directory of your MT installation.
  2. Change the permissions of the /plugins/Pagination/pages.cgi script to 755 (CHMOD 755).
  3. 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.
  4. Return to the settings and click the "Install Templates" button. This will install the templates mentioned above.
  5. Setup your .htaccess file with the Pagination rules, as described above.
  6. Edit your Main Index template and add the following before the </MTEntries> tag:

    <mt:EntriesFooter>
    <mt:Include module="Pagination">
    </mt:EntriesFooter>

  7. Modify your <MTEntries tag to include the argument offset="$pagination_offset". This is important. Example: <MTEntries lastn="10" offset="$pagination_offset">

  8. (Pro only) Do the same for your "Entry Listing" archive template, for both MTEntries containers.

  9. (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".

  10. (Pro only) If you want to paginate long entries on your Entry archives, edit your Entry archive (or relevant template module) to replace or modify the EntryBody or EntryMore tags, as described above.

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

Get Pagination

Pagination is free for personal or commercial use, but you must leave the "powered by" link, which is added automatically below the paginations links.

Download Now

Membership required, please sign-in or register:

As always, comments, questions, and suggestions are welcome.

Rate this entry:

  • Currently 4.2/5
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 4.2/5 (8 votes cast). Powered by the Ajax Rating plugin.

TrackBack

TrackBack URL for this entry:

Listed below are links to weblogs that reference Pagination 1.5 - Create Multi-Page Entries:

» Интересное в блогосфере про Movable Type #4 from Movable Type
Очередная подборка интересных новостей о Movable Type. Вышло обновление связки шаблонов (скина) Mid-Century, теперь он выглядит так: Среди обновлений Mid-Century: Комментирование на AJAX Подсветка комментариев автора поста Javascript виджет фотогалереи... [Read More]

» صفحه بندی مطالب با پلاگین Pagination 1.5 from مووبل تایپ فارسی
یکی از دغدغه های همیشگی وبلاگ نویسان آرشیو مطالب وبلاگ هست.سیستمهایی نظیر مووبل تایپ و وردپرس این امکان رو تنها با چند کلیک در اختیار کاربر قرار قرار میدن. امروز هم پلاگینی رو معرفی میکنم که کمک زیادی به وبلاگ... [Read More]

» Pagination, Cache Block, MT Forum from Movable Type
Pagination, Cache Block, MT Forum — это три интересных плагина от Марка, позволяющие сделать Movable Type ещё лучше. Pagination — плагин для разбивки на страницы, собственно, пейджинации. Интересен он потому, что нормальной пейджинации для ... [Read More]

» Blog Issues... from Shadowscope
...we all have them sometime.Anyway, I am working on a couple of things to streamline the site again, such as pagination so if the site acts freaky It won't be long before it's working correctly again.One of the things I... [Read More]

» Internet Radio from Internet Radio
Die besten Anbieter sind gratis und ohne Werbung. [Read More]

Comments (30)

Pouya [TypeKey Profile Page]:

great, thanks mark :)

Shahab [TypeKey Profile Page]:

Thank you for develop this plugin.

Pouya [TypeKey Profile Page]:

i used some php code in my template, in the index page every thing is fine, but in other pages my Php codes dose not work, is there any way to fix this problem?

dramnok [TypeKey Profile Page]:

Mark,

I purchased Pagination Pro 1.4 but haven't been able to run it because of a problem noted in my comments to the 1.4 thread. I'm hoping 1.5 will fix that problem, but I don't see a way to download the Personal License version without repaying. Do I have to repay to get this new version, or am I missing something?

dramnok, you should have received an automated email with a download link to the new version. If you didn't, you can use the contact link above.

Also note that there was never a 1.4 version...

Jason Truell [TypeKey Profile Page]:

Hi Mark,

Nice plugin. I got the plugin installed fine and it is paginating my entry listing pages (I have a pro license) but it is not sorting the entries the way I want. I have the sort_by of mt:Entries set to a custom field. The Pagination plugin is taking the 10 most recent entries from my blog and then sorting those by my customfield for page one, then taking the next ten entries and sorting those by my customfield for page 2, etc.

Is there anyway to have all the entries sorted by my customfield with sort_by and then have pagination plugin paginate the entries in that order? I hope you can respond soon as I'm a time crunch to get this working.

Thanks
Jason

Hi Jason,

The Pagination plugin doesn't actually directly control the sorting or deciding what entries to display. Rather, the core mt:Entries tag does that, and the Pagination plugin merely passing the value for the "offset" argument, for pages 2+. One thing to try, is change the "lastn" parameter of mt:Entries to "limit", so it might look something like:

<mt:Entries sort_by="field:foo" limit="10" offset="$pagination_offset">

I am having a problem with the pagination displaying the same 10 entries on all pages.

Is there a way to have different entries on the pagse?

Any help is appreciated!

ikonwire [TypeKey Profile Page]:

I'm having the same problem as getdagoss had

"I am having a problem with the pagination displaying the same 10 entries on all pages.

Is there a way to have different entries on the pagse?

Any help is appreciated!"

How were you able to solve it? Please help!

devil [TypeKey Profile Page]:

ikonwire: I am not an expert, but it sounds like a htaccess issue.

devil [TypeKey Profile Page]:

I never did have any luck with the include htaccess file (maybe it's a none-pro thing). It did redirect, but it showed the full (ugly) url, and not a beautiful one.

About htaccess, make sure you've renamed htaccess.txt to .htaccess, and make sure that your site supports htaccess (and mod_rewrite).

Personally, I wrote my own htaccess with more user friendly urls such as site.com/page/1 instead of site.com/index.html?page=1

All in all, a great plugin! I'm probably going to buy the pro version just to support its development

If you are having template problems (i.e the pagination works, but displays the wrong template/old template) it is most likely due to that you have enabled caching in your pagination settings, but for some reasons you don't have the cache plugin installed. Or it's corrupt / not working. Try disabling the cache settings.

ikonwire [TypeKey Profile Page]:

Thanks devil. It was the htaccess file.
The problem I have now is that I am using some php code to make my header banners rotate. When I installed the Pagination plugin the first page on the index looks great but when I click on "Next Page" the php code for my header gets stripped out and the page displays wrongly.

Can anyone help with this.

www.youmustbetrippin.com/index_test.php

seyhan:

I never did have any luck with the include htaccess file (maybe it's a none-pro thing) film izle online film izle indirmeden film izle

. It did redirect, but it showed the full (ugly) url, and not a beautiful one.

About htaccess, make sure you've renamed htaccess.txt to .htaccess, and make sure that your site supports htaccess (and mod_rewrite).

Personally, I wrote my own htaccess with more user friendly urls such as site.com/page/1 instead of site.com/index.html?page=1

All in all, a great plugin! I'm probably going to buy the pro version just to support its development

AsLan:

Thank

chat:

teşekkurler ozgur

canım benim thanks

chat:

ekleyin bakalım nereye kadar

Rob D.:

To be clear, does comment pagination work with static pages?


. It did redirect, but it showed the full (ugly) url, and not a beautiful one.

About htaccess, make sure you've renamed htaccess.txt to .htaccess, and make sure that your site supports htaccess (and mod_rewrite).

Personally, I wrote my own htaccess with more user friendly urls such as site.com/page/1 instead of site.com/index.html?page=1

All in all, a great plugin! I'm probably going to buy the pro version just to support its development Restaurant Restaurant

saeed [TypeKey Profile Page]:

Hi Mark, I've installed the plugin, but I received un error when i clicked on the next page bottom. the error is "The requested URL /plugins/Pagination/pages.cgi was not found on this server."
What should I do?
Thanks

Hi there. I bought the Pro version so I could paginate long entries, and I've installed it and messed with it but can't get it to work. No matter which "page" (part) I look at, I get the first page of the content. I've tried a few different things and just am hitting a brick wall. Can you help? I am willing to pay for consulting if it is necessary. I really need this feature for a new section of my site.

Thanks!

~Angela

http://www.1top.ro - Cel mai mare director web romanesc. Adrese site-uri pe categorii. Informatii si resurse on-line din domenii diverse, precum IT, lifestyle, moda, magazine, afaceri, imobiliare, mass-media..

Post a comment

Gift idea: Buy Seinfeld DVD box set, complete 9 seasons!