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