We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3232
    • 380 Posts
    I was able to get this plugin to do what I wanted.

    I will classify this as a beta since I am not an expert php coder. It appears to be working properly for me.

    any questions or comments would be greatly apprecited.

    Thanks
    Brian
      • 21642
      • 23 Posts
      The 2nd version - with pagination do nothing for me:
      it put page 1/2/3 for example, but I see the whole content on every page. I’m missing something?
        • 3232
        • 380 Posts
        Quote from: nlcluigi at Jun 27, 2007, 03:58 AM

        The 2nd version - with pagination do nothing for me:
        it put page 1/2/3 for example, but I see the whole content on every page. I’m missing something?

        If you are talking about the version I created then you will need to create a style in your css:

        .hidepage {display:none;}

        the purpose of this is to hide the "other pages" when viewing it on screen but it allows you to create a print style sheet and in this style sheet you can set the hidden fields to be visible. therefore the entire story or article will print but only one page will be visible on screen.
          • 33423
          • 27 Posts
          is it possible to give titles for pagination links or are there any addons for that function like joomla’s pagebreak bot.
          for ex.
          {BREAK=Overview}
          {BREAK=Specifications}
          {BREAK=Conclusion}

          And the link are overview, specifications and conclusions instead of next page or page numbers.

            • 33372
            • 1,611 Posts
            Just thought I’d post a slightly different version of this resource in case anyone else finds it useful. I use it as a snippet instead of a plugin (since I only needed to paginate a few documents). Place the snippet call in place of [*content*] in your template to use it this way.

            I also added links to each individual page instead of just Previous and Next.

            Very minor changes, but maybe someone will use them...

            <?php
            $delimiter = '{BREAK}';
            $tplLinkNext = '   <a href="[+link+]">Next</a>';
            $tplLinkPrev = '<a href="[+link+]">Previous</a>   ';
            $tplLinkNav = '
            <div style="margin:10px auto;width:100%;text-align:center;"><p>Page [+current+] of [+total+]<br />
            [+linkprev+] [+pagelinks+] [+linknext+]</p></div>
            ';
            
            $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=');
            
               $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);
            
               $pagelinks='';
               for($i=1;$i<=$pip_pagecount;$i++){
                  if($i==$pip_currentpage) $pagelinks.=' [ '.$i.' ] ';
                  else $pagelinks.=' <a href="'.$url.$i.'">'.$i.'</a> ';
               }
            
               $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("[+pagelinks+]",$pagelinks,$pip_template);
            
               $pip_content=$pip_template.$pip_pagecontent[$pip_currentpage-1].$pip_template;
               
            }
            
            return $pip_content;
            ?>
            
              "Things are not what they appear to be; nor are they otherwise." - Buddha

              "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

              Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
              • 29703
              • 217 Posts
              Sorry to revive this thread, but I have a quick question.

              On a lot of sites tha pagination navigation appears at both the top and bottom of the page. Is it possible to create multiple instances of the pagination navigation, or how would I go about modifying it so I would be able to?

              Thanks smiley
                • 33372
                • 1,611 Posts
                You could just add the navigation snippet twice on the page (and if the snippet calls and page are cached, the code will only be executed the first time the page is loaded anyway). Or you could set a MODx plugin at the end of the snippet and use it as many times as you like on the page. You’d do that with something like:

                $modx->setPlaceholder(’page_navigation’,$pip_content);

                and then you can just place the placeholder [+page_navigation+] wherever you like.
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 3232
                  • 380 Posts
                  Did this stop working for anyone with the .9.6.1 update? once I updated, now when i click the next page button... the ?page=2 is appended to the url but is just displays the first page content.

                  ---edit

                  It seems to be a caching issue. did modx change the way it caches items? It seems this was an old problem (looking at the beginning of this thread)
                    • 25663 MODX Staff
                    • 12,272 Posts
                    Is the page now set to be cacheable and/or (if used from Zap above) the snippet called cached?
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 3232
                      • 380 Posts
                      Quote from: rthrash at Feb 01, 2008, 08:35 AM

                      Is the page now set to be cacheable and/or (if used from Zap above) the snippet called cached?

                      I’m using the original plugin (50% of my documents have multiple pages.)

                      I have page caching on by default. I haven’t had any problems using this plugin this way until i upgraded to 6.1

                      If i set it so the page does not cache then the plugin starts to work correctly.

                      The only thing with this is that its going to be tough going through 200+ documents and changing them all to non-cacheable... nevermind the increased server load.

                      Rather then downgrading to .9.6 i am going to use the snippet above uncached