We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7527
    • 437 Posts
    I have a snippet call on my template called DittoAZ and is uncached. The call links to a php coding that incorporates a Ditto call (which has to be cached). Due to this reason my pagination will not work (as I have been told for it to work the calls have to be uncached) but I cannot have both calls uncached. Can someone please help, as this has taken me all day to sort and this is the final piece of the puzzle to sort!!!
      www.PawsForWildlife.co.uk
      www.Borntobrick.co.uk
      • 7527
      • 437 Posts
      This is my call

      [!DittoAZ!]
      <p>Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles</p>
      <div id="ditto_pages"> [+previous+] [+pages+] [+next+] </div>


      And hidden in my DittoAz snippet is the following call

      [[Ditto? &parents=`70,80` &extenders=`glossaryFilter` &hideFolders=`1` &depth=`3` &display=`20` &orderBy=`pagetitle ASC` &filterBy=`' . $cur_filter . '` &tpl=`Dittosearch` &forceUTF8=`1` &paginate=`1`]]


      With this setup I get 20 results on my page with a ’next’ link. I follow it and get a blank page with nothing, even though at the beginning it said there were 3 pages of results.
        www.PawsForWildlife.co.uk
        www.Borntobrick.co.uk
        • 16278
        • 928 Posts
        hidden in my DittoAz
        How exactly? What does DittoAZ look like?
        huh KP
          • 7527
          • 437 Posts
          It looks like this...

          <?php
          /*
           BuildGlossary_post - this snippet runs Ditto with glossaryFilter in default mode
           Released under the terms of General Public License
           Copyright (c) 2010 Aleksander Maksymiuk, http://setpro.pl/software/ditto-stuff/glossary-extender
          */
          
          # the following array serves for both building the index and validating user's requests
          $allowed_req = array(
              # 'label-for-button-or-link' => 'actual-value-for-regex-clause',
              '0-9' => '0|1|2|3|4|5|6|7|8|9',
              'A' => 'A',
              'B' => 'B',
              'C' => 'C',
              'D' => 'D',
              'E' => 'E',
              'F' => 'F',
              'G' => 'G',
              'H' => 'H',
              'I' => 'I',
              'J' => 'J',
              'K' => 'K',
              'L' => 'L',
              'M' => 'M',
              'N' => 'N',
              'O' => 'O',
              'P' => 'P',
              'Q' => 'Q',
              'R' => 'R',
              'S' => 'S',
              'T' => 'T',
              'U' => 'U',
              'V' => 'V',
              'W' => 'W',
              'X' => 'X',
              'Y' => 'Y',
              'Z' => 'Z',
              'ALL' => 'A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z',
          );
          
          # validate user's request
          $cur_filter = isset($_POST['filter']) && isset($allowed_req[$_POST['filter']]) && $allowed_req[$_POST['filter']] ? $allowed_req[$_POST['filter']] : '';
          
          # build index
          $index = '<form method="post" action="[~[*id*]~]" style="margin: 15px 0 15px 0; padding: 0 20px 0 40px;">';
          foreach ($allowed_req as $label => $request) {
              if ($request) {
                  $index .= '<input type="submit" name="filter" value="' . $label . '"' . ($request == $cur_filter ? ' disabled="disabled"' : '') . ' />' . ' ';
              }
          }
          $index .= '<input type="submit" name="clear" value="Clear Listing" />' .
          '</form>';
          
          # generate output
          return $index . ($cur_filter ?
              # valid request encountered - build document listing with extended Ditto (default extender mode)
           '[[Ditto? &parents=`70,80` &extenders=`glossaryFilter` &hideFolders=`1` &depth=`3` &display=`20` &orderBy=`pagetitle ASC` &filterBy=`' . $cur_filter . '` &tpl=`Dittosearch` &forceUTF8=`1` &paginate=`1` &tplPaginatePage=`pageSplitter` &tplPaginateCurrentPage=`currentPageSplitter`]]'  :
          
            # empty, "clear", or invalid request encountered - do not generate anything
              ''
          );
          ?>
            www.PawsForWildlife.co.uk
            www.Borntobrick.co.uk
            • 16278
            • 928 Posts
            Ho hum! I don’t think I’d start from there, personally. But why not try making the "embedded" Ditto call uncached, anyway? If that doesn’t work, try making the containing page non-cacheable (in its Settings tab).
            rolleyes KP
              • 7527
              • 437 Posts
              Tried both, still no page 2 or 3! Lost at where to look to be honest. It isn’t my snippet, I just modified it to suit my needs, obviously I am missing something. Thanks for the suggestions though, it is appreciated
                www.PawsForWildlife.co.uk
                www.Borntobrick.co.uk
                • 7527
                • 437 Posts
                Another approach. Does anyone know how to amend the php, to stop it relying on the Ditto call inside its code. For example, the php snippet code does not need the Ditto call. When I call for it on my template, it will only be the one call. Make sense?
                  www.PawsForWildlife.co.uk
                  www.Borntobrick.co.uk
                  • 4310
                  • 2,310 Posts
                  Something like :
                  <?php
                  $params['parents']='70,80';
                  $params['tpl']='Dittosearch'; 
                  $params['forceUTF8']='1'; 
                  $params['paginate']='1'; 
                  $params['tplPaginatePage']='pageSplitter'; 
                  $params['tplPaginateCurrentPage']='currentPageSplitter'; 
                  $params['orderBy']='pagetitle ASC'; 
                  $params['hideFolders']='1'; 
                  $params['filter']= $cur_filter; 
                  $params['display']='20'; 
                  $params['depth']='3';
                  $params['extenders']='glossaryFilter';
                  return $modx->runSnippet('Ditto',$params); 
                  ?>
                    • 7527
                    • 437 Posts
                    Thanks Bunk. How would I integrate that into my original php?
                      www.PawsForWildlife.co.uk
                      www.Borntobrick.co.uk
                      • 4310
                      • 2,310 Posts
                      Untested and a bit of a guess.
                      <?php
                      /*
                       BuildGlossary_post - this snippet runs Ditto with glossaryFilter in default mode
                       Released under the terms of General Public License
                       Copyright (c) 2010 Aleksander Maksymiuk, http://setpro.pl/software/ditto-stuff/glossary-extender
                      */
                      
                      # the following array serves for both building the index and validating user's requests
                      $allowed_req = array(
                          # 'label-for-button-or-link' => 'actual-value-for-regex-clause',
                          '0-9' => '0|1|2|3|4|5|6|7|8|9',
                          'A' => 'A',
                          'B' => 'B',
                          'C' => 'C',
                          'D' => 'D',
                          'E' => 'E',
                          'F' => 'F',
                          'G' => 'G',
                          'H' => 'H',
                          'I' => 'I',
                          'J' => 'J',
                          'K' => 'K',
                          'L' => 'L',
                          'M' => 'M',
                          'N' => 'N',
                          'O' => 'O',
                          'P' => 'P',
                          'Q' => 'Q',
                          'R' => 'R',
                          'S' => 'S',
                          'T' => 'T',
                          'U' => 'U',
                          'V' => 'V',
                          'W' => 'W',
                          'X' => 'X',
                          'Y' => 'Y',
                          'Z' => 'Z',
                          'ALL' => 'A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z',
                      );
                      
                      # validate user's request
                      $cur_filter = isset($_POST['filter']) && isset($allowed_req[$_POST['filter']]) && $allowed_req[$_POST['filter']] ? $allowed_req[$_POST['filter']] : '';
                      
                      # build index
                      $index = '<form method="post" action="[~[*id*]~]" style="margin: 15px 0 15px 0; padding: 0 20px 0 40px;">';
                      foreach ($allowed_req as $label => $request) {
                          if ($request) {
                              $index .= '<input type="submit" name="filter" value="' . $label . '"' . ($request == $cur_filter ? ' disabled="disabled"' : '') . ' />' . ' ';
                          }
                      }
                      $index .= '<input type="submit" name="clear" value="Clear Listing" />' .
                      '</form>';
                      $params['parents']='70,80';
                      $params['tpl']='Dittosearch'; 
                      $params['forceUTF8']='1'; 
                      $params['paginate']='1'; 
                      $params['tplPaginatePage']='pageSplitter'; 
                      $params['tplPaginateCurrentPage']='currentPageSplitter'; 
                      $params['orderBy']='pagetitle ASC'; 
                      $params['hideFolders']='1'; 
                      $params['filter']= $cur_filter; 
                      $params['display']='20'; 
                      $params['depth']='3';
                      $params['extenders']='glossaryFilter';
                      $custom_filter = $modx->runSnippet('Ditto',$params); 
                      # generate output
                      return $index . ($cur_filter ?  $custom_filter  :   '');
                      ?>