Add a "paging" feature to nodes, so that nodes with long content can be paged.

Desired functionality would be to have two modes:

  1. Manual Page Breaks: have an indicator such as < ! -- page -- > that can be inserted by the node author where page breaks should go.
  2. Auto-paging: as an option, the admin should be able to turn on auto-paging. Much like 4.2.x's teaser functionality, it can be set to automatically page after XXXX characters.

The url would likely look something like /node/view/111/2

Another function might be to have a link on paged nodes that turns off paging to view an entire long article on one page: /node/view/111/full

Would it be useful to turn on/off paging on a per-node basis? Perhaps set by default in admin -> content management -> content settings

See this thread for a longer discussion.

Comments

moshe weitzman’s picture

idilas’s picture

Does the last post mean that node pagination was added to 4.2?
Is it available in 4.4?

gjost’s picture

Version: » 4.6.0

Here's a quick attempt to solve the issue. It checks $node->body to see if there are any occurrances of <!--page-->. If there are, it checks to see if a particular page of the node or the entire node is being requested, and then displays only the requested portion.

  • URLs look like this:
    /node/111/view/2 (section 2 of the node)
    /node/111/view/all (the entire node)
  • Printer-friendly link displays the entire node.
  • Right now it only checks for '<!--page-->' (no spaces).
  • There's no auto-paging setting or settings in admin.
  • You turn off paging for a node by not including any <!--page--> tags. :)
Index: node.module
===================================================================
--- node.module (revision 2282)
+++ node.module (working copy)
@@ -514,6 +514,77 @@
   // TODO: this strips legitimate uses of '<!--break-->' also.
   $node->body = str_replace('<!--break-->', '', $node->body);

+
+
+  // display the proper portion of a multi-page document
+  // use '<!--page-->' (without quotes) to set breaks
+  if (strpos($node->body, '<!--page-->')) {
+
+    // figure out which page is requested
+    $thispage = $_GET['view'];
+    if (($thispage == null) || ($thispage == '')) {
+      $thispage = 1;

+    }
+
+    // skip this if viewing entire page or no pager requested
+    if (($thispage != 'all') && (is_numeric($thispage))) {
+
+      // construct pager
+      global $base_url;
+      $pageurl = "$base_url/node/".$node->nid."/&view=";
+
+      $firstpage = 1;
+      $prevpage = $thispage-1;
+      $nextpage = $thispage+1;
+      $lastpage = count($pages);
+
+      $pager = "<div id=\"pager\" class=\"container-inline\" style=\"width:100%\">";
+
+      // first
+      if ($prevpage >= $firstpage) {
+        $pager .= "  <div class=\"pager-first\"><a href=\"$pageurl$firstpage\">first</a></div>";
+      }
+      else {
+        $pager .= "  <div class=\"pager-first\">first</div>";
+      }
+
+      // previous
+      if ($prevpage >= $firstpage) {
+        $pager .= "  <div class=\"pager-previous\"><a href=\"$pageurl$prevpage\">prev</a></div>";
+      }
+      else {
+        $pager .= "  <div class=\"pager-previous\">prev</div>";
+      }
+
+      $pager .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+
+      // next
+      if ($nextpage <= $lastpage) {
+        $pager .= "  <div class=\"pager-next\"><a href=\"$pageurl$nextpage\">next</a></div>";
+      }
+      else {
+        $pager .= "  <div class=\"pager-next\">next</div>";
+      }
+
+      // last
+      if ($nextpage <= $lastpage) {
+       $pager .= "  <div class=\"pager-last\"><a href=\"$pageurl$lastpage\">last</a></div>";
+      }
+      else {
+       $pager .= "  <div class=\"pager-last\">last</div>";
+      }
+      $pager .= "</div>\n";
+
+      // display only this page's content
+      $pages = explode('<!--page-->', $node->body);
+      $node->body = $pages[$thispage-1].$pager;
+    }
+
+  }
+
+
   // The 'view' hook can be implemented to overwrite the default function
   // to display nodes.
   if (node_hook($node, 'view')) {
boris mann’s picture

Version: 4.6.0 » x.y.z
Status: Active » Closed (won't fix)

There is a "paging" module available in contrib. Marking as won't fix.