Basically there is this great plugin that allows you to paginate articles simply by placing [page] in your body field. The plugin generates the pages and navigation on the fly. The problem is that it only provides the option of listing pages as numbers and doesnt allow you to title your pages either.
Enter the Arkham Hack, a modification which allows you to place [page Title Goes Here] and also shows your title as a teaser link for the next page. As far as I can tell, here is the bit of code that handles this... note the references to "teaser"
Code: Select all
function etz_pg_body($atts) {
global $thisarticle;
$pageSep = etz_pg_break();
if (is_array($atts)) extract($atts);
$pgerr = isset($pgerr) ? $pgerr : 'Invalid page number!';
$notrim = isset($notrim) ? $notrim : false;
$pg = etz_pg_thispage();
$pages = preg_split($pageSep, $thisarticle['body']);
$max = count($pages) + 1;
$linkstub = etz_pg_linkstub();
preg_match_all($pageSep, $thisarticle['body'], $matches);
$teaser = $matches[1][$pg-1];
if ($pg == "all") {
return join("\n", $pages);
}
else {
if (isset($pages[$pg-1])) {
$pagecontent = $pages[$pg-1];
if (($pg > 1) && (!($notrim))) $pagecontent = substr($pagecontent, 4);
if (($pg < $max) && (!($notrim))) $pagecontent = substr($pagecontent, 0, -3);
if (!empty($teaser)) return $pagecontent.'<p id="teaserTxt"><a href="'.$linkstub.($pg + 1).'">'.$teaser.'</a></p>';
else return $pagecontent;
}
else {
return '<p>'.$pgerr.'</p>';
}
}
}My aim is to take it a step further and have all the titles show up as an unordered navigation list..
Here are a few clues from Arkham's post on how to accomplish this:
So I took his advice and decided to poke around with the "nonumbers" function which creates the current navigation:(to modify this) as an overall navigation option (a list of all page titles). The nav function can be easily modified to handle that by making use of the same code from etz_pg_body:
preg_match_all($pageSep, $thisarticle[‘body’], $matches);
$matches [ 1 ][0] would now have the 1st page title. $matches [ 1 ][1] the second and so on…
In this case you’d need to add another option to the tag etz_pg to control whether this type of page title navigation should be used
Code: Select all
if (!($nonumbers)) {
for ($i = 1; $i <= $max; $i++) {
$out[] = '<li class="pgNum';
if ($i == $max) {
$out[] = ' pgLast';
}
if ($pg != $i) {
if ($i == 1) {
$out[] = '"><a href="'.$base_url.'">';
}
else {$out[] = '"><a href="'.$linkstub.($i).'">';
}
}
else {
$out[] = ' pgCurrent">';
}
$out[] = $i;
if ($pg != $i) $out[] = '</a>';
$out[] = ' ';
$out[] = '</li>';
}
}I feel like I am close to the solution but missing a small nudge in the right direction. How would you tackle this problem?