We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7527
    • 437 Posts
    Hi all. I have tried getting help with this before but to no avail, so desperately trying again in vain.
    My snippet works but it seems to only find 90 articles . The 2 folders I have specified in my call house at least 300. My alphabet at the top of the page only has a handful of active letters and I dont know why.

    My snippet is
    <?php
    $docid = $modx->documentIdentifier;
    $parents = isset($parents) ? $parents : $docid;
    $dittoTpl = isset($tpl) ? $tpl : "listingtpl"; // ditto tpl to use
    $display = isset($display) ? $display : "20"; // number of items per page to return
    $filterBy = isset($_GET["letter"]) ? strtoupper($_GET["letter"]) : "";
    $filter = "pagetitle,".$filterBy.",11";
    
    //-- Alphabet Letters
    $letter = array (
    	"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"
    );
    
    $table = $modx->getFullTableName("site_content");
    
    foreach($letter as $l){
    	$sql = "SELECT $table.id, $table.pagetitle FROM $table WHERE ( $table.pagetitle LIKE '$l%') AND ($table.parent IN ($parents)) LIMIT 1";
    	$results = $modx->db->query($sql);
    	$count = $modx->db->getRecordCount( $results );
    	if ($count > 0) {
        	$letters .= "<a href=\"[~".$docid."~]&letter=".$l."\">".$l."</a>|";
    	} else {
        	$letters .= $l."|";
    	}
    }
    
    // get count for pagination
    $v = '';
    if($filterBy != ""){
    	$sql = "SELECT $table.id, $table.pagetitle FROM $table WHERE ( $table.pagetitle LIKE '$filterBy%') AND ($table.parent IN ($parents))";
    	$results = $modx->db->query($sql);
    	$v = $modx->db->getRecordCount( $results );
    }
    // run ditto snippet
    $output = $modx->runSnippet("Ditto", array(
    	"debug" => "0",
    	"parents" => $parents,
    	"depth" => "3",
    	"display" => $display,
    	"paginate" => "1",
    	"paginateAlwaysShowLinks" => "0",
    	"sortBy" => "pagetitle",
    	"sortDir" => "ASC",
    	"tpl" => $dittoTpl,
    	"filter" => $filter,
                         "total" => "all",
                         "extender" => "glossaryFilter",
                         "hideFolders" => "1",
                         "tplPaginatePage" => "pageSplitter",
                         "tplPaginateCurrentPage" => "currentPageSplitter",
    	"tplPaginatePrevious" => "@CODE <li><a href='[+url+]'>Previous</a></li>\n",
    	"tplPaginateNext" => "@CODE <li><a href='[+url+]'>Next</a></li>\n",
    	"tplPaginateNextOff" => "@CODE <li><a href='[~[*id*]~]#'>Next</a></li>\n",
    	"tplPaginatePreviousOff" => "@CODE <li><a href='[~[*id*]~]#'>Previous</a></li>\n",
    	"tplPaginatePage" => "@CODE <li><a href='[+url+]'>[+page+]</a></li>\n",
    	"tplPaginateCurrentPage" => "@CODE <li class='selected'><a href='[~[*id*]~]#'>[+page+]</a></li>\n" ));
    
    //$pages = "<ul id=\"paging\">
    //[+previous+] 
    //[+pages+] 
    //[+next+]
    //</ul>\n";	
    
    //$v = count($output);
    
    $modx->setPlaceholder('a2zletters', $letters);
    $modx->setPlaceholder('a2z', $output);
    $modx->setPlaceholder('pages', $pages);
    return "<p>".$letters."</p> ".$output.$pages;
    ?>


    My call is
     [!Ditsy? &parents=`70,80` &tpl=`Dittosearch`!]
    <p>Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles | Page <strong>[+currentPage+]</strong> of <strong>[+totalPages+]</strong></p> <div id="ditto_pages"> [+previous+] [+pages+] [+next+]</div>
    

    And the offending page is http://www.pawsforwildlife.co.uk/index.php?q=617.html&letter=B&start=20
      www.PawsForWildlife.co.uk
      www.Borntobrick.co.uk
      • 16278
      • 928 Posts
      Does
      "extenders" => "glossaryFilter",
      (adding the "s") make any difference?
      smiley KP
        • 7527
        • 437 Posts
        Hi KP52. No unfirtunately not. All I get are the active letters A,B,F,I,M and R.

        All my published docs are found in folders 70 and 80 at a depth of 3 levels. I can’t understand why it will find some but not all? It’s really strange
          www.PawsForWildlife.co.uk
          www.Borntobrick.co.uk
          • 7527
          • 437 Posts
          Well I think I have narrowed down the problem a bit. I think it is with the code on my template
          <p>Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles | Page <strong>[+currentPage+]</strong> of <strong>[+totalPages+]</strong></p> <div id="ditto_pages"> [+previous+] [+pages+] [+next+]</div>
          


          As I have used this in many templates to trial and it fails in all. It returns one page, but any ’next’ pages are blank and my active letters are still incomplete
            www.PawsForWildlife.co.uk
            www.Borntobrick.co.uk
            • 7527
            • 437 Posts
            Found the culprit! well sort of. It is the &depth parameter. For some reason it is ignoring some of my folders when I use a depth of 3, through published containers
              www.PawsForWildlife.co.uk
              www.Borntobrick.co.uk