We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26270
    • 5 Posts
    I am interested in using ModX for a site I am building, but I REALLY need the ability to break content into separate pages, especially with regards to long articles. I’ve download the PIP plugin, but it doesn’t seem to work with the latest version of ModX. Tried searching the forums but didn’t really come up with any answers or solutions. Any help would be greatly appreciated.

    Thanks,
    Sean
      • 14930
      • 70 Posts
      One way to do it is to use Ditto and have a long article split into several documents. I also think (I’m not sure about this) that you can use Ditto to display a shorter version of a long text and have for example a "Read more.." link which displays all of the article. Check out the compiled documentation attached here http://modxcms.com/forums/index.php/topic,13533.0.html (I’ve found that document extremely useful) and of course the Ditto subforum.
        • 25951
        • 9 Posts
        You can just insert {BREAK} into your content at any place and it will start paginating it. If you insert two breaks, you will get 3 pages. Be careful with caching issues though.

        And I am not sure how to change the standard output yet. Dunno where I stumbled upon that info either.
          • 16892
          • 107 Posts
          There’s a plugin called Pagination Plugin (Pip) that allows you to use {BREAK} to paginate a long document.

          Name: Pip (Pagination Plugin)
          * Version: 1.0
          * Author: Armand "bS" Pondman ([email protected])
            • 38669
            • 51 Posts
            I couldn't get pip to work in revolution - here is my replacement code. Be sure turn off caching for any pages where you use it.

            /*
             *	Name: Pip (Pagination Plugin)
             *	Version: 2.0
             *	Original Author: Armand "bS" Pondman ([email protected])
             *      v2.0 Modified by:   Valeska "Spellsmith" Scholl ([email protected])
             *	Updated: January 20, 2009 07:00 CET
             *      v2.0 Modified by:   Steve Davis ([email protected])
             *	Updated: June 6th 2012
             *
             *  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
             *
             *  Notes:  The links for First and Last only appear if you are not on the first, second, (last-1), or last page.
             *               There's no point in having a "first" link when you're only on page 2, for example.
             *
             *   CSS classes:  
             *                div.pagination controls the styling for the First, Previous, Next, and Last links, 
             *                as well as the "Page X of Y".  
             * 
             *                div.pagelist_div controls the actual list of individual pages (the entire list - "1 2 3 4 5").
             *
             *                span.pagelist controls the individual page numbers in the pagelist ("1", "2", "3")
             *
             *
             *  Change log:
             *
             *  v2.0 - Added "First" and "Last" page jump links.  
             *            Added list of individual pages jump links.
             *            Added 'pagination', 'pagelist', and 'pagelist_div' classes which can be used for CSS styling.
             *            Added ModX placeholder "total_pagecount" which can be used in chunks for formatting.  
             *            [Useful for links that need to go to the last page (i.e. linking to comments / comment forms).]
             */
            
            ## CUSTOMIZE ##
            $delimiter = '{BREAK}';
            $tplLinkNext = '<a href="[+link+]">Next »</a>' ;
            $tplLinkPrev = '<a href="[+link+]">« Prev</a>';
            $tplLinkFirst = '<a href="[+link+]" class="small">< First</a> ';
            $tplLinkLast = ' <a href="[+link+]" class="small">Last ></a>';
            $tplPageList = '<div class="pagelist_div">[+link+]</div>';
            
            $tplLinkNav = '
              <div class="pagination">
              [+linkfirst+]
              [+linkprev+]
               Page [+current+] of [+total+] 
              [+linknext+] 
              [+linklast+]
            <br />
            [+pagelist+]
              </div>';
            
            ## DO NOT EDIT BELOW THIS LINE ##
            $e = &$modx->Event;
            
            switch($e->name) {
              case 'OnLoadWebDocument':
                    $thecontent = $modx->resource->get('content');
            
                    if ($_GET["print"]) {
                         $thecontent = str_replace($delimiter, '', $modx->resource->get('content')); 
                        return;
                     }  // Failsafe to PREVENT pagination for printing.
            
                    $pip_content = $thecontent ;
                    $pip_pagecontent = explode($delimiter, $pip_content);
            	$pip_pagecount = count($pip_pagecontent);
            
            //echo "name = " .  $pip_pagecount . "<br>" . $pip_content; exit;
            /* ADDED:  LastPageURL */
            $modx->setPlaceholder('total_pagecount',$pip_pagecount);
            
            	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->resource->get('id'),'',$char.'page=');
            	  
            	  $prevpage = $pip_currentpage-1;
            	  $nextpage = $pip_currentpage+1;
            
            /* Generate Page List */
                     $counter = 1;
                     while ($counter <= $pip_pagecount) {
                          $pagelist .= '<span class="pagelist"><a href="' . $url . $counter . '" class="small">' . $counter . '</a></span>';
                          $counter++;
                     }
                    
            	  
            	  $linkprev = ($prevpage>0) ? str_replace("[+link+]",$url.$prevpage,$tplLinkPrev) : '';
            	  $linknext = ($nextpage>$pip_pagecount) ? '' : str_replace("[+link+]",$url.$nextpage,$tplLinkNext);
                      $linkfirst = ($prevpage >1) ? str_replace("[+link+]",$url."1",$tplLinkFirst) : '';
            	  $linklast = ($nextpage>($pip_pagecount-1)) ? '' : str_replace("[+link+]",$url.$pip_pagecount,$tplLinkLast);
                      $linklist = str_replace("[+link+]",$pagelist,$tplPageList);
            	  
            	  $pip_template = str_replace("[+linkfirst+]",$linkfirst,$tplLinkNav);
            	  $pip_template = str_replace("[+linkprev+]",$linkprev,$pip_template);
            	  $pip_template = str_replace("[+linknext+]",$linknext,$pip_template);
            	  $pip_template = str_replace("[+linklast+]",$linklast,$pip_template);
            	  $pip_template = str_replace("[+total+]",$pip_pagecount,$pip_template);
            	  $pip_template = str_replace("[+current+]",$pip_currentpage,$pip_template);
                      $pip_template = str_replace("[+pagelist+]",$linklist,$pip_template);
            	
            	  $pip_content= $pip_pagecontent[$pip_currentpage-1].$pip_template;
            	}
            	$modx->resource->set('content',$pip_content);
            
                break;
              default:
                return;
                break;
            }