Skip to content
  1. Extras
  2. PageBreaker

PageBreaker

Plugin that splits long page content into multiple subpages.

How it works

The plugin looks for separators in the page content (default <!-- pagebreak -->). When found, it splits the page at those points and generates links to the next parts.

When following such a link, MODX does not find a real page (it does not exist) and fires OnPageNotFound. The plugin handles this event, computes the requested content part and outputs it.

So you get several "virtual" pages from one real page.

Demo

See the plugin in action on the demo site.

Demo

Features

  • Works with cached resources.
  • Runs only when the content has separators.
  • Includes a PageBreak plugin for TinyMCE (TypoMCE) for automatic text splitting.
  • Supports friendly URLs.
  • Supports regular documents and containers.

Chunks

The following chunks are used for pagination:

NameDescriptionPlaceholders
tpl.PageBreaker.beginLink to the first page[[+link]] — page link
tpl.PageBreaker.nextLink to the next page (may be empty)[[+link]] — page link
tpl.PageBreaker.prevLink to the previous page (may be empty)[[+link]] — page link
tpl.PageBreaker.outerBlock with all links[[+pb_link_prev]], [[+pb_link_next]], [[+pb_link_begin]] — links, [[+pb_page]] — current page number, [[+pb_total]] — total pages

On the first or last page, the previous or next link is not generated. This lets you handle those cases with output filters and put the link at the start of the document. That is how the standard outer chunk works:

modx
<div class="pagebreaker">
  [[+pb_link_prev]]

  <span class="pb_page_current">[[+pb_page]]</span>
  [[%pb_page_from]]
  <span class="pb_page_total">[[+pb_total]]</span>

  [[+pb_link_next:default=`[[+pb_link_begin]]`]]
</div>

Ajax

The plugin can work in Ajax mode (switch pages without reload).

  • Enable the system setting pagebreaker_ajax
  • Page links must have the class pb_link. Check if you changed the default chunks.
  • The [[*content]] tag must be wrapped in an element with #pagebreaker_content (can be changed in pagebreaker_ajax_selector).

Example:

modx
<div id="pagebreaker_content">
  [[*content]]
</div>

In Ajax mode the plugin uses the JavaScript History API, so the URL updates as without Ajax. No extra parameters in the address bar.

For older browsers, a hash in the URL is used.