We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31601
    • 57 Posts
    I know that many people haven’t considered this plugin, but I find that for articles in a fixed background area div it’s great because I can paginate and keep the look I like. One thing I don’t like, though, was that there was no inclusion of first/last navigation in the plugin, so I appended a bit of code in a complete hacker style (I’m no PHP guru, that’s for sure!) to the great work by Armand "bS" Pondman ([email protected]). If anybody wants to use this, here it is....

    /**
     *	Name: Pip (Pagination Plugin)
     *	Version: 1.0
     *	Author: Armand "bS" Pondman ([email protected])
     *      Inclusion of next/last navigation by Virgil Rockford ([email protected])
     *	Updated: August 29, 2007 12:00 EDT
     *
     *  Description:
     *  will paginate a document when delimiter is found in the content. 
     *
     *  Configuration:
     *  check the OnLoadWebDocument event
     *
     *    optional: 
     *      Edit the values under the CUSTOMIZE Header
     *
     */
    
    ## CUSTOMIZE ##
    $delimiter = '{NewPage}';
    $tplLinkNext = '<a href="[+link+]">></a>';
    $tplLinkPrev = '<a href="[+link+]"><</a>';
    $tplLinkLast = '<a href="[+link+]">>></a>';
    $tplLinkFirst = '<a href="[+link+]"><<</a>';
    $tplLinkNav = '
      <div style="font-size:small;clear:both;"><p align="center">
      [+linkfirst+] [+linkprev+]
       Page [+current+] of [+total+] 
      [+linknext+] [+linklast+]
     </p></div>';
    
    ## DO NOT EDIT BELOW THIS LINE ##
    $e = &$modx->Event;
    
    switch($e->name) {
      case 'OnLoadWebDocument':
        $pip_content = $modx->documentObject['content'];
    	$pip_pagecontent = explode($delimiter,$pip_content);
    	$pip_pagecount = count($pip_pagecontent);
    	
    	if ($pip_pagecount > 1)
    	{
    	  $pip_currentpage = isset($_GET["page"]) ? $_GET["page"]: 1;
    	  if ($pip_currentpage > $pip_pagecount || $pip_currentpage < 1) { $pip_currentpage = 1; }
    	
    	  $char = ($modx->config['friendly_urls'] == 0) ? "&" : "?";
    	  $url = $modx->makeurl($modx->documentObject["id"],'',$char.'page=');
              $docbase = $modx->makeurl($modx->documentObject["id"]);
              
    	  
    	  $prevpage = $pip_currentpage-1;
    	  $nextpage = $pip_currentpage+1;
    	  
    	  $linkprev = ($prevpage>0) ? str_replace("[+link+]",$url.$prevpage,$tplLinkPrev) : '';
    	  $linknext = ($nextpage>$pip_pagecount) ? '' : str_replace("[+link+]",$url.$nextpage,$tplLinkNext);
      
              if ($pip_currentpage == 1)
              $linkfirst = "";
              else
              $linkfirst = str_replace("[+link+]",$docbase,$tplLinkFirst);
     
              if ($pip_currentpage == $pip_pagecount)
              $linklast = "";
              else 
              $linklast = str_replace("[+link+]",$url.$pip_pagecount,$tplLinkLast);
              
    	  $pip_template = str_replace("[+linkprev+]",$linkprev,$tplLinkNav);
    	  $pip_template = str_replace("[+linknext+]",$linknext,$pip_template);
    	  $pip_template = str_replace("[+total+]",$pip_pagecount,$pip_template);
    	  $pip_template = str_replace("[+current+]",$pip_currentpage,$pip_template);
              $pip_template = str_replace("[+linklast+]",$linklast,$pip_template);
    	  $pip_template = str_replace("[+linkfirst+]",$linkfirst,$pip_template);
    	  
              $pip_content= $pip_pagecontent[$pip_currentpage-1].$pip_template;
    	}
    	$modx->documentObject['content'] = $pip_content;
    
        break;
      default:
        return;
        break;
    }
    


    Hoping this helps out anybody who would like a bit of functionality added to the plugin! I used chevrons for the naviation- you can modify the display for your links easily.

    Fixed using the < and > symbols so that the output will validate.