I’ve done a snippet so that long articles can be diplayed over a number of pages. Mark the point(s) in the article with a delimeter and the snippet will break the page at that point.
The snippet call is:
[[paginate]], which uses the default delimiter of {page}
or
[[paginate? &delimiter=`!!!cheese!!!`]] to specify a delimiter of !!!cheese!!!
There are a number of issues with it as it currently stands-
1. You can’t use the front end QuickEdit with the paginated output. Non paginated pages still work OK.
2. TinyMCE (and possibly other RTEs) wraps the delimiter in stupid <p></p> tags. You will see I have tried and failed to strip them out in the snippet. Maybe someone with better PHP knowledge can assist here but until then you can manually remove them in the HTML view.
3. The forward/backward page navigation need restyling, or templating.
Anyway, I don’t want to spend any more time on it as I have many more things to do, so feel free to use it, hack it, or ignore it.
// Get page data
$currentid = $modx->documentObject['id'];
$tvOutput = $modx->getTemplateVarOutput('content', $currentid);
$content = $tvOutput['content'];
// Split into separate pages
$sdelimiter = isset($delimiter) ? "$delimiter" : "{page}";
$pages = explode($delimiter,$content);
$numPages = count($pages);
if ($numPages>1)
{
// Work out where we are. Note: page numbering starts at 1
$currentPage = isset($_GET["page"]) ? $_GET["page"]: 1;
$prevPage = $currentPage-1;
$nextPage = $currentPage+1;
$pageNums = " Page $currentPage of $numPages ";
// Work out links to previous and next pages
$tvOutput = $modx->getTemplateVarOutput('alias', $currentid);
$char = ($modx->config['friendly_urls'] == 0) ? "&" : "?";
$link = '[~'.$currentid.'~]'.$char.'page=';
$backlink = ($prevPage>0) ? "<a href='$link$prevPage'><--Prev</a>" : ' ';
$fwdlink = ($nextPage<=$numPages) ? "<a href='$link$nextPage'>Next--></a>" : ' ';
// Make links. Could use a template for this but it's a bit of an overkill
$pageNav="<div id='pgpagenav'><p style='float:left;width:10%;text-align:right'>$backlink</p><p style='float:left;width:20%;text-align:center'>$pageNums</p><p style='float:left;width:10%;text-align:left'>$fwdlink</span></div>";
// Output the page
$output = $pages[$currentPage-1];
# if (substr($output, 1, 4)=="</p>") $output = substr($output, 5);
# if (substr($output, -3, 3)=="<p>") $output = substr($output, 1, -3);
return "<div>$pageNums</div>".$output.$pageNav;
}
else return "[*#content*]";