We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7527
    • 437 Posts
    Thanks. Tried the snippet and got the following:


    Parse error: syntax error, unexpected ’[’ in /homepages/17/d313524938/htdocs/manager/includes/document.parser.class.inc.php(770) : eval()’d code on line 53
      www.PawsForWildlife.co.uk
      www.Borntobrick.co.uk
      • 4310
      • 2,310 Posts
      There was a missing $ on the first $params, now corrected rolleyes
        • 7527
        • 437 Posts
        Thanks Bunk. Okay well no parse error. But does not show any results either?!?
          www.PawsForWildlife.co.uk
          www.Borntobrick.co.uk
          • 7527
          • 437 Posts
          I seem really close to getting this nailed. Does anyone know why Bunk’s code does not return any results? The call for it is [!Dittotest?!]
            www.PawsForWildlife.co.uk
            www.Borntobrick.co.uk
            • 3749
            • 24,544 Posts
            Here are some guesses:

            The $parents parameter would have to contain the IDs of actual documents on your site that have children.
            All the docs have to be published and not hidden from menus.
            You’d have to have a Tpl chunk named DittoSearch with the appropriate placeholders in it.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 7527
              • 437 Posts
              Hi BobRay thanks for the response.
              my $param parents have containers that have published documents (at a depth of 2)
              All the docs are published and not hidden

              My Ditto search tpl chunk is as follows:

              <div class="grid3">  
                  <em><a href="[~[+id+]~]">[+pagetitle+]</a></em>  
              <br>
               <p>[+summary+]</p>
              
              
              </div> 
              
                www.PawsForWildlife.co.uk
                www.Borntobrick.co.uk
                • 3749
                • 24,544 Posts
                What happens when you call Ditto directly with all those params set as they are in Bunk58’s code?

                The best method with any snippet that calls runSnippet() is to get the call working by calling the target snippet directly with the same parameters first.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 7527
                  • 437 Posts
                  Bunks code is in a snippet called Dittotest. I call it on my template - [!Dittotest?!]
                  My placeholders are in a chunk ’Dittosearch’
                  When called it returns 0 of 0 articles

                  If I just call Ditto from inside the snippet as follows:
                  <?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
                      ''
                  );
                  ?>

                  I get articles returned but pagination breaks. Page 1 is fine, but page 2 returns 0 articles
                    www.PawsForWildlife.co.uk
                    www.Borntobrick.co.uk