We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19800
    • 180 Posts
    is there any way to do this?
    pagination is very critical instrument in catalogue creation, but with pagination and phx ditto can work only on uncashed page
    such page loading slowly and heavily loads server processor

    what can be done, is there any cahcing mechanisms maybe?
      • 36416
      • 589 Posts
      Quote from: mk99 at Apr 02, 2009, 09:24 AM

      pagination is very critical instrument in catalogue creation, but with pagination and phx ditto can work only on uncashed page
      such page loading slowly and heavily loads server processor
      what can be done, is there any cahcing mechanisms maybe?

      I suggest rewriting Ditto pagination as external (helper) snippet, starting point could be SplitPagination for example... then call that particular Ditto region (see id parameter) and corresponding MySplitPages uncached, everything else stays cached.
        • 19800
        • 180 Posts
        Quote from: Eol at Apr 02, 2009, 01:38 PM

        then call that particular Ditto region (see id parameter) and corresponding MySplitPages uncached, everything else stays cached.

        i’m using splitpagination, but it’s not working on cashed page too, What particular Ditto region i need to call, can you be more specific? Sorry, don’t understand.
          • 36416
          • 589 Posts
          Quote from: mk99 at Apr 02, 2009, 08:54 PM

          i’m using splitpagination, but it’s not working on cashed page too, What particular Ditto region i need to call, can you be more specific?

          Here’s fixed SplitPagination, call it on cached page with PHx, immediately after your Ditto id=`a` call:
          [!DittoPageSplit? &id=`a` &output=`1`!]

          Change templating inside last (if $output) block:
          <?php //only for forum highlighting
          // Place immediately following a Ditto call
          // Based on the function written by Aaron Hall, evilwalrus.org
          // Ditto 2.1 start page fix & PHx workaround: Eol ([email protected])
          if (!function_exists("generatePagination")) {
           function generatePagination($curPage, $totResults, $resultsPerPage) {
            $totPages = ceil($totResults / $resultsPerPage);
            $pagesBefore = $curPage - 1;
            $pagesAfter = $totPages - $curPage;
            $tabArr = array();
            if ($totPages > 15) {
              if ($pagesBefore > 7) {
                $tabArr = array(1, 2, 0);
                if ($pagesAfter > 7) {
                  for ($i=($curPage-4); $i<$curPage; $i++) { $tabArr[] = $i; }
                } else {
                  for ($i=($totPages-11); $i<$curPage; $i++) { $tabArr[] = $i; }
                }
              } else {
                for ($i=1; $i<$curPage; $i++) { $tabArr[] = $i; }
              }
              $tabArr[] = $curPage;
              if ($pagesAfter > 7) {
                if ($pagesBefore > 7) {
                  for ($i=($curPage+1); $i<=$curPage+4; $i++) { $tabArr[] = $i; }
                } else {
                  for ($i=($curPage+1); $i<13; $i++) { $tabArr[] = $i; }
                }
                $tabArr[] = 0;
                $tabArr[] = $totPages-1;
                $tabArr[] = $totPages;
              } else {
                for ($i=($curPage+1); $i<=$totPages; $i++) { $tabArr[] = $i; }
              }
            } else {
              for ($i=1; $i<=$totPages; $i++) { $tabArr[] = $i; }
            }
            return $tabArr;
           }//function generatePagination end
          }
          
          $id = isset($id) ? $id.'_' : '';
          $total = isset($total) ? $total : $modx->getPlaceholder($id."total");
          $start = isset($start) ? $start : $modx->getPlaceholder($id."urlStart");
          $summarize = isset($summarize) ? $summarize : $modx->getPlaceholder($id."perPage");
          $currentPage = isset($currentPage) ? $currentPage : $modx->getPlaceholder($id."current");
          $landing = isset($tagDocumentID) ? $tagDocumentID : $modx->documentObject['id'];
          if ($total == 0 || $summarize == 0) {
            return false;
          }
          $page = ($start/$summarize)+1;
          $output = isset($output) ? $output : 0;
          $paginationArray = generatePagination($page, $total, $summarize);
          $ph = "";
          $cInc = $_GET[$id.'start'];
          foreach ($paginationArray as $page) {
            $inc = ($page-1) * $summarize;
            if ($page == 0) { 
              $ph .= "..."; // represents pages that aren't displayed
            } else if ($inc == $cInc) {
              $ph .= "<span class=\"active\">{$page}</span>";
            } else {
              $ph .= "<a class=\"page\" href=\"".ditto::buildURL("start=".$inc, $landing, $id)."\">{$page}</a>\n";
            }
          }
          $modx->setPlaceholder("{$id}pagesplit", $ph);
          if ($output) { return "
           <div class=\"pages\">
            <strong>[+{$id}start+]</strong>-<strong>[+{$id}stop+]</strong> od <strong>[+{$id}total+]</strong>
            [+{$id}previous+] {$ph} [+{$id}next+]
           </div>";
          }
          


          See it working here:
          http://www.burzanautike.com/testovi?a_start=10
            • 19800
            • 180 Posts
            thank you!
            it’s just AWESOME!!!
            laugh
              • 19800
              • 180 Posts
              tested
              all is working, but it will work only when being called after ditto call, not before
              but if catalogue is big enought it needs 2 paging calls
              before and after

              can i accomplish this with your method?
                • 36416
                • 589 Posts
                Quote from: mk99 at Apr 06, 2009, 08:38 AM

                but if catalogue is big enought it needs 2 paging calls
                before and after
                can i accomplish this with your method?

                Sorry, no.
                  • 20413
                  • 2,877 Posts
                  @EOL: THANKS!!  smiley

                  I’m getting pagination like 1 2 ... 1 2 3 4 5 6 7 8 ... 10 11 12

                  1+2 gets repeated when I clicked 5.

                  And going backwards clicking 10 I get: 1 2 ... 10 11 12 only
                    @hawproductions | http://mrhaw.com/

                    Infograph: MODX Advanced Install in 7 steps:
                    http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                    Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • 36416
                    • 589 Posts
                    Quote from: mrhaw at Apr 06, 2009, 09:32 AM

                    I’m getting pagination like 1 2 ... 1 2 3 4 5 6 7 8 ... 10 11 12
                    1+2 gets repeated when I clicked 5.

                    Are you calling pagination uncached on cached page after Ditto call with valid &id ?
                    I can give you only "it works here" right now...
                      • 20413
                      • 2,877 Posts
                      EDIT!!
                      I had conflicting code all over!!!!! IT WORKS NICE NOW!!!

                      So nice! This made my day!!
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower