January 12, 2003
- updated March 3, 2007
(Download)
This plugin is free for personal use. For commercial use a $20 license is required.
Important: The MTPaginate tags generate PHP code. In order
to use these tags, your blogs must reside on a server that supports PHP and
your blog files must have an appropriate PHP extension (usually .php). See this page for more information.
Purpose
Some web pages generated by MovableType may grow quite large. For example, a category archive with hundreds of entries or an individual entry archive with dozens of comments may become unmanagebly large.
The MTPaginate plugin makes it possible for the single web page that MovableType generates to be displayed as multiple pages, with easy navigation between them.
Pagination of a list of entries
Following is an example of a simple
Index template. This template generates links and excerpts for the last
20 entries and breaks it on section (<$MTPaginateSectionBreak$>)
boundaries into pages of less than 1000 bytes, each.
Each page will contain one or more entries. If there is more than one
page, the <MTPaginateNavigator>
tag will create a popup menu
that jumps to the individual pages.
Following is an example of a simple Individual
Entry Archive template using the MTPaginate tags. This template takes the
entry text and breaks it on paragraph (<p>) boundaries into pages
of less than 800 words, each. Each page will contain one or more paragraphs
(if the first paragraph is more than 800 words, the page will
only contain that one paragraph). If there is more than one page, the <MTPaginateNavigator>
tag will create a list of links to the individual pages (1 |
2 | 3 | 4).
Example: The Long Articles
Blog uses the MTPaginate tags to break a listing of articles into several
pages, and to break individual entry archives into multiple pages.
The MTPaginate tags automatically break up specified (long) content in a single
document into multiple pages. You can let the user navigate between the pages
using Previous and Next links, a list of page
numbers (1 | 2 | 3 | 4) or a
selection menu
. You configure pagination by specifying section breaks within your document
and the maximum size that multiple sections are allowed to be before a new page
is created.
MTPaginate
Container tag that must enclose all other pagination tags. You can provide
one of the following optional attributes:
page_selector=”name”
Specifies which URL parameter name is used for page selection. The default
page_selector is "page". You would need to change the
default page_selector only if your page uses the page
parameter for some other purpose.
page_section_selector=”name”
Specifies which URL parameter name is used for page section selection. The default
page_section_selector is "page_section". You would need to change the
default page_section_selector only if your page uses the page_section
parameter for some other purpose.
default_page="1" or "first" or "last" or "all"
Specifies the page number that is displayed by default. Besides specifying
a number, you can also use "first" or "last", for first or last page,
respectively, or "all" to display all pages at once. By default, the
first page is displayed.
base_address=”_relative” or "_absolute" or "URL"
This parameter can be used to specify that type of links built by the
page navigation tags. You can specify a concrete URL or use "_relative"
(i.e. document.php?page=3) or "_absolute" (i.e. http://www.yoursite.com/blog/page.php?page=3).
By default, page navigation uses relative links.
debug=”1”
This parameter can be used during the development of your template to
displays entire contents of the document as a list of sections. By default,
debug is disabled.
mode="php" or "cgi"
Specifies whether the generated page will be processed by PHP or displayed
by a CGI, such as the mt-search.cgi. The default mode is "php".
MTPaginateIfSinglePage
Conditional tag that is true if all content fits into a single page.
MTPaginateIfMultiplePages
Conditional tag that is true if the content has been split into two
or more pages. To only show the navigation links when there are multiple pages,
use the following code:
MTPaginateVersion
Returns the current version of the MTPaginate plugin.
Page Navigation
Addressing by page:You can use the page parameter to specify which page should be displayed. The parameter can have a numeric value (1 for first page, 2 for second page, …) or you can use the logical value first for the first page and last for the last page.
For example, the following URLs would address the first, third and last page, respectively.
Addressing by page section:When you generate a paginated list of items, you can identify each section using the MTPaginateSectionID container tag. You can then use the page_section parameter to target the page containing the specified section id.
For example, if you have a paginated listing of comments, you might want to use the comment ID as your MTPaginateSectionID:
If both a page and page_section parameter is specified, the page identified by the page_section parameter is selected.
MTPaginatePreviousPageLink
Link to the previous page of a multi page document. If currently the first
page is being displayed, then MTPaginatePreviousPageLink is empty.
To show a link to the previous page - if there is one, use the following code:
MTPaginateNextPageLink
Link to the next page of a multi page document. If currently the first page
is being displayed, then MTPaginateNextPageLink is empty. To
show a link to the next page - if there is one, use the following code:
MTPaginateAllPagesLink
Link to display all pages of a multi page document at once. To show a link
to all the pages - if there there are more than one pages, use the following
code:
MTPaginateNavigator
Links to some or all of the pages in a multi-page document. See the navigator
sampler pages for examples of this tag. You can use the following attributes
to modify this tag:
anchor="#anchor"
If specified, the linke generated by MTPaginator include this anchor.
style="navigator style"
Specifies the display style of the navigation. The can be one of the following
values - the default is "links":
format="%d" Specified the format of the text used in the list of links or
popup menu. The default value is "%d". Example, to display "Page
1 | Page 2 | Page 3 | Page 4",
use the following code:
<$MTPaginateNavigator format="Page %d">
format_title="%d" Specified the format of the text used for the link title in
the list of links; it is only used
in the "links" display style. Some browsers
display the link title when the user hovers with the mouse over the link.
The default value is "" or
empty title. For example, to specify "Page <page number>" as the title,
use the following code:
<$MTPaginateNavigator format_title="Page %d">
format_current="%d" Specifies the format of the text used for the current
page in the list of links or popup menu. The default value is the same
as that of the format attribute. For example, to make the current
page number bigger "1 | 2
| 3 | 4", use
the following code (the format "<font size=+1>%d</font>"
must be converted into HTML entities when it’s placed into the attribute):
format_all="text" When this attribute is specified, the navigators adds a link
that displays all pages at once. Be default, format_all is empty.
Specified the format of the text used in the list of links or popup menu.
For example, to display "All 4 Pages | Page
1 | Page 2 | Page 3 | Page 4",
use the following code:
<$MTPaginateNavigator format_all="All %d Pages">
format_all_title="text" Specified the format of the text used for the link title in
on the link used to display all pages at once; it is only used
in the "links" display style in conjunction
with the format_all attribute. Some browsers display the link
title when the user hovers with the mouse over
the link.
The default value is "" or
empty title. For example, to specify "Display all pages at once" as
the title, use the following code:
<$MTPaginateNavigator format_all="All Pages" format_all_title="display all pages at once">
format_all_current="text" Specifies the format of the text in the list of links or popup
menu used when all pages are currently
selected. The default
value is the same as that of the format_all attribute. For example,
to display "[ All Pages ] | Page
1 | Page 2 | Page 3 | Page 4",
use the following code:
<$MTPaginateNavigator format_all="All Pages" format_all_current="[ All Pages ]">
place_all="before" or "after"
Specifies whether to to put the link to display all pages before (All
Pages | 1 |
2 | 3
| 4) or after (1 |
2 | 3 | 4 | All Pages)
the links to individual pages. The default is to put the linkbefore the
individual pages. For example, if you only
want to put the link to all pages after the links to individual pages,
use the following code:
list_pages="before" or "after" or "all"
Specifies whether to list all (1 | 2 | 3
| 4) pages or only pages before (1)
or after (3 | 4) the
current page. The default is to list all pages. For example, if you only
want to list pages before the current page, use the following code:
<$MTPaginateNavigator list_pages="before">
separator=" , "
Specifies the separator between the links in the list; it is only used
in the "links" display style. The default
value is " | ". For example, to display "1,
2, 3, 4", use he following
code:
<$MTPaginateNavigator separator=", ">
target="name"
Specifies the target attribute of links; it is only used
in the "links" display style. By default
no target is specified. For example, to always make the page open in
the same window, use the following code:
<$MTPaginateNavigator target="_self">
Page Number
MTPaginateNumPages
Number of pages into which content was paginated.
MTPaginateCurrentPage
Page number of current page.
MTPaginatePreviousPage
Page number of previous page, if any.
MTPaginateNextPage
Page number of next page, if any.
MTPaginateNumSections Number of section into which content was divided.
MTPaginateTopSection
Section number of the first section on current page.
MTPaginateCurrentSection
Section number of the current section.
MTPaginateBottomSection
Section number of the last section on current page.
Page Conditions
The page condition tags allow you to display text based on which page is displayed.
The page condition tags which end with an underscore (_) are different from
standard MovableType condition tags because they generate PHP code. This means
that you must use the single <MTPaginateElse_> tag instead of
the <MTElse> container tags.
The following truth table shows when each of the conditional tags evaluate
to a true value:
Tag
Single Page
First Page
Subsequent Pages
Last Page
All Pages
First Section
Last Section
MTPaginateIfFirstPage_
true
true
true
MTPaginateIfMiddlePage_
true
MTPaginateIfLastPage_
true
true
true
MTPaginateIfPreviousPage_
true
true
MTPaginateIfNextPage_
true
true
MTPaginateIfAllPages_
true
MTPaginateIfPageHeader_
true
MTPaginateIfPageFooter_
true
MTPaginateIfFirstPage_
Enclosed text is displayed if the current page is the first page of a multi-page
document, or if there is only one page.
MTPaginateIfLastPage_
Enclosed text is displayed if the current page is the last page of a multi-page
document, or if there is only one page.
MTPaginateIfMiddlePage_
Enclosed text is displayed if there are multiple pages and the current page
is not the first or last page.
MTPaginateIfPreviousPage_
Enclosed text is displayed if there are multiple pages and the current page
is not the first page.
MTPaginateIfNextPage_
Enclosed text is displayed if there are multiple pages and the current page
is not the last page.
MTPaginateIfAllPages_
Enclosed text is displayed if there are multiple pages and all pages have
been selected.
MTPaginateIfPageHeader_
Enclosed text is displayed if the current section is the first section
on the current page.
MTPaginateIfPageFooter_
Enclosed text is displayed if the current section is the last
section on the current page.
MTPaginateElse_
This tag can only be used inside one of the MTPaginateIf…_ conditional
tags. The text that follows is displayed if the condition of the tag evaluates
as false.
The following example displays a large header on the first page and a smaller
header with navigation links on subsequent pages of a multi-page document:
The page condition tags allow you to display text based on which page id displayed.
The page condition tags which end with an underscore (_) are different from
standard MovableType condition tags because they generate PHP code which means
that you must use the single <MTPaginateElse_> tag instead of
the <MTElse> container tags.
MTPaginateContent
This container tag encloses text that is to be paginated. You can modify its
behavior using the following attributes:
max_words="n"
Specifies the maximum number of words in a page of content. The default
value is 400 words.
max_bytes="n"
Specifies the maximum number of bytes in a page of content. If specified,
the max_words attribute is ignored.
max_sections="n"
Specifies the number of sections in a page of content. If specified, the
max_words and max_bytes attributes are ignored.
section_start_tag="p"
Specifies the tag that indicates the beginning of a new section. When
the content is paginated, a page break will be inserted in front of
the
specified tag, if necessary. By default, no section_start_tag
is specified.
To break up content before paragraph <p> tags, use the following
code:
section_start="section start"
Specifies any text which indicates the beginning of a new section. When
the content is paginated, a page break will be inserted in front of
the
specified text, if necessity. The section_start attribute overrides
the section_start_tag attribute. By default, no section_start_tag
is specified.
To break up content before <div class="section">
tags, use the following code (note that the value must be converted into
HTML entities when it’s placed into the attribute):
section_break="text"
Specifies the text that indicates separation between two sections. When
the content is paginated, a page break will be inserted at the location
of the specified text, if necessary. The section_break text
is removed from the document during pagination. By default, the section_break
is “__MTPAGINATE_SECTION_BREAK__”.
To specify the text <p>——</p> as a section separator,
use the following code:
page_break="text"
Specifies the text that indicates separation between two pages. When the
content is paginated, a page break will always be inserted at the location
of the specified text. The section_break text is removed from
the document during pagination. By default, the page_break is
“__MTPAGINATE_PAGE_BREAK__”.
To specify the text <p>====</p> as a section separator,
use the following code:
MTPaginateSectionBreak
Indicates a section break. When the content is paginated, a page break will
be inserted at the location of the MTPaginateSectionBreak tag,
if necessary.
MTPaginateSectionID
Container tag whose contents specify the ID of the current section. This ID can be used as the value of the page_section URL parameter to specify the page that contains this section.
MTPaginatePageBreak
Indicates a page break. When the content is paginated, a page break will always
be inserted at the location of the MTPaginateSectionBreak tag.
MTPaginateStaticBlock
This container tag encloses a static block that is included in the generated output at specific intervals. This tag is useful to include advertisements in the generated listing. You may have multiple MTPaginateStaticBlock tags in the paginated content, for example one to use on the first page and another one to use on subsequent pages.
section="3, 8, 10"
Required attribute that specifies in which section on each page the static block should appear.
For example, if you want to display an ad after the second entry in your listing, you would specify section=”2”. If you want the same block to also appear after the 7th entry, you would specify section=”2, 7”
page="1" or "2, *".
Optional attribute that specifies on which page the static block should appear.
For example, if you want to display an ad only on the first page, you would specify page=”1”. If you want a block to appear on all but the first page, you would specify page=”2, *” (the * means “all following pages”).
Version History
1.28 March 3 2007
Enabled for Plugin Manager.
New tags:
1.27 February 22 2007
Fixed generated PHP to always use long PHP tags.
Optimized plugin s.t. majority of the code is only loaded when needed.
New tags:
Will MTPaginate show up in the “Plugins” list in the settings, once I’ve installed it? I’ve dropped it into the plugins directory several times but it never shows up there, and I was wonderng if that was a problem or just due to it not being configurable from the main admin page for plugins.
MTPaginate should show up in the global Plugins listing assessible from the MT home page. But it will not show up in a Blog’s plugins listing because there is no per-blog configuration for it.
Thank you very much for this plug in. Terrific job. Works like a charm. I just sent you a license fee via PayPal.
Newbies like me might appreciate the following example of using your plugin on the primary index page of one’s blog (homepage)…. my notes to newbies are within {}’s :
{Note: MT PAGINATE currently will not work if MT is set to DYNAMIC PUBLISHING}
<MTPaginate>
<MTPaginateContent max_sections="10"> {note: This controls display of 10 entries per page}
<MTEntries lastn="99999"> {Note: this controls the max number of entries to retrieve for paging purposes. IE, if this number is 120 and entries are displayed at 10 per page (see above), you will get nav links to 12 pages....}
<p>
<b><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></b>
<$MTEntryExcerpt$>
</p>
<$MTPaginateSectionBreak$> {Note: Very important to have this in your code}
</MTEntries>
</MTPaginateContent>
<MTPaginateIfMultiplePages>
<div><$MTPaginateNavigator$></div> {Note: Standalone tag defaults to page numbers}
</MTPaginateIfMultiplePages>
<MTPaginateIfPreviousPage_>
<a href="<$MTPaginatePreviousPageLink$>">Previous Page</a>
</MTPaginateIfPreviousPage_>
<MTPaginateIfNextPage_>
<a href="<$MTPaginateNextPageLink$>">Next Page</a>
</MTPaginateIfNextPage_>
</MTPaginate>
I have implemented MTPaginate on my site, www.gpsmagazine.com, to help drive pageview traffic and divide long posts. I had one hell of a time getting it working, but now it finally is working, except for a formatting issue: The individual entry pages on my site use the 2-column left layout. At the end of each entry on my site, the comments appear below the fold as if the page is a single column. For an example of what I’m talking about, visit http://www.gpsmagazine.com/2006/12/magellan_roadmate_2200t_review.php?page=14
Notice how the entry ends, and you have scroll down to the end of the left column before you can see the comments people have posted.
How can I have MTpaginate include the comments in the pagination correctly?
I assume that you’re using the section_start_tag attribute to tell MTPaginate where it’s safe to break up content. This works fine as long as you don’t nest <p> tags inside of other tags, which is what happens with your comments. In your case, MTPaginate produces a page that’s no longer valid HTML.
I don’t see a good work around for this issue, except maybe to keep your comments in a separate template and paginate them on their own. I.e. you’d end up with a magellan_roadmate_2200t_teview.php page, which would paginate the article, but not the comments, and a magellan_roadmate_2200t_teview_comments.php page which would contain the paginated comments. And when paginating the comments, you should use the [MTPaginateSectionBreak] tag to indicate section breaks.
So I have MTPaginate working perfectly the way I want:
frontpage: 3 posts, static image, 7 posts [next page]
Now, is there anyway to have the page2 results with the same arrangement? 3:image:7 ? Currently MTPaginate is outputting page2 with 10 posts with no breaks.
I am trying to get the pagination working on my page, can someone tell me if I need to add the code that Peter Bakke posted (comment 144) on the individual archive page as well as the index.php? I am very green with this MT so any help examples would be helpful.
Regarding navigation… rather than be encumbered with a list of 40 or more pages, I’d like to display something like this: 1 2 3 4 5 …. 40 >> (next 5, or 10) etc.
Could you suggest whether and how this might be possible using page condition tags?
We can now get the mt paginate to work but on our index and category pages we have ads under the 1st, 2nd, and then the 4 and 5 post - then the page is ad free. How do we use mtpaginate to not include the entries with ads on every page? Because we start mt-paginate at the 5 article? Do we wrap the entire thing in mt-paginate?
hi all.. among any other pagination plugins for mt out there, this is my favourite choice! been using it in every mt site i made..
anyway, got 1 situation here i dont know how to solve.. how if we want to make the pagination like this?
previous|1|2|3|4|5|…|{n}|next
where {n} is the last page available in the pagination list. coz currently it work by displaying all page number, right! if the total reach 20-30, im sure it will look ugly.. so, any idea? i really want to know if the “…|{n}” is possible to do using this plugin.. thanks!
Stepan, this plugin is displaying what seems to be some seriously broken or at least random behavior. Could you explain why
even one single quote(‘) in the format attribute completely breaks the page and not if it’s used within the format_current attribute?
This is making it an enormous PITA to get the results I need.
I’m using Dynamic Publishing (DP). I notice in one of the comments that MTPaginate does NOT support DP. Is that still the case, because it seems like a great plugin that everyone needs. If not, then do you have any plan to convert it into php version? Thanks.