Hi everyone,
got a little problem with the A2Z Snippet ...
e.g. if i got a site structure like
-
res (id2)
- sub res01
- sub res02
-
sub res03 (id4)
--- subsub01
--- subsub02
- sub res03
- sub res04
and call the Snippet [!A2Z? &parents=`2`!] it
doesn’t grab the ressources within container "sub res03(id4)" automatically, although the Ditto parameters within the Snippet say so ... if i add the container id to the Snippet call [!A2Z? &parents=`2,4`!] it works.
+ if i declare the letter which should be used as default:
$filterBy = isset($_GET["letter"]) ? strtoupper($_GET["letter"]) : "A";
and the only ressource starting with an "A" is within container(id4), the Snippet will list the ressource, but not display letter "A" as an active link within the A to Z listing at the top -> see screenshot below
if i move the ressource one level up (direct child of id2) it works.
this is the Snippet code in use:
<?php
$docid = $modx->documentIdentifier;
$parents = isset($parents) ? $parents : $docid;
$dittoTpl = isset($tpl) ? $tpl : "a2z-template"; // ditto tpl to use
$display = isset($display) ? $display : "all"; // number of items per page to return
$filterBy = isset($_GET["letter"]) ? strtoupper($_GET["letter"]) : "A";
$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 .= "<span>" . $l . "</span>";
}
}
// 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" => "4",
"display" => $display,
"paginate" => "0",
"paginateAlwaysShowLinks" => "0",
"sortBy" => "pagetitle",
"sortDir" => "ASC",
"tpl" => $dittoTpl,
"filter" => $filter,
"language" => "german",
"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" ));
//$v = count($output);
// $modx->setPlaceholder('a2zletters', $letters);
$modx->setPlaceholder('a2z', $output);
$modx->setPlaceholder('pages', $pages);
return "<p class=\"lexicon\">".$letters."</p> ".$output.$pages;
?>
can anyone spot in the Snippet code why ressources within the subfolder aren’t displayed?
btw. i also tried different caching options without success.
thanks, j