Go for it!
<?php
$parentId = isset($parentId) ? $parentId : '0';
$level = isset($level) ? $level : '100';
$includeParent = isset($includeParent) ? $includeParent : '0';
$includeDocId = isset($includeDocId) ? $includeDocId : '';
$excludeDocId = isset($excludeDocId) ? $excludeDocId : '';
$excludeParentId = isset($excludeParentId) ? $excludeParentId : '';
$lastChildOnly = isset($lastChildOnly) ? $lastChildOnly : '0';
// result array
$docs = array();
// all parents
$parents = array();
// all ids to be excluded
$remove = array();
// get all children
foreach (explode(',', $parentId) as $pId) {
$childs = $modx->getChildIds($pId, $level);
$docs = array_merge($docs, $childs);
if ($pId != 0) {
$parents[] = $pId;
}
}
/////////////////////// include
// add parents
if ( (boolean) $includeParent == true) {
$docs = array_merge($docs, $parents);
}
// add includeDocId
if ($includeDocId != '') {
$docs = array_merge($docs, explode(',', $includeDocId));
}
/////////////////////// get last children
if ( (boolean) $lastChildOnly == true) {
$tblContent = $modx->getFullTableName('site_content');
// if a document has an isfolder flag, this query will not select it, even if it has no childs
// $sql = "SELECT id FROM $tblContent WHERE isfolder=0 ";
//
// here isfolder flag doesn't matter, we count only the documents with no childs
// ignore isfolder flag for SQL 4.1+
// $sql = "SELECT id FROM $tblContent WHERE id NOT IN (SELECT parent FROM $tblContent) ";
//
// ignore isfolder flag for SQL <4.1
$sql = "SELECT a.id FROM $tblContent AS a LEFT JOIN $tblContent AS b ON a.id = b.parent WHERE b.parent IS NULL";
$res = $modx->dbQuery($sql);
$childs = array();
while ($row = $modx->db->getRow($res)) {
$childs[] = $row[id];
}
$docs = array_intersect($docs, $childs);
}
/////////////////////// remove
// remove excludeDocId
if ($excludeDocId != '') {
$remove = explode(',', $excludeDocId);
}
// remove excludeParentId
foreach (explode(',', $excludeParentId) as $pId) {
$childs = $modx->getChildIds($pId, $level);
$remove = array_merge($remove, $childs);
// remove parents listed in exludeParentId
if ( (boolean) $includeParent == true) {
$remove[] = $pId;
}
}
// remove
$docs = array_diff($docs, $remove);
$docs = array_unique($docs);
return implode(', ', $docs);
?>
SELECT ...... WHERE (sc.id IN ( myList )) AND .....
) is to add the id list in line 146 and 179 of the AjaxSearch.inc.php (right after the" WHERE"; ).
$sql = " SELECT id FROM modx_site_content ";
$res = $modx->dbQuery($sql);
$childs = array();
while ($row = $modx->db->getRow($res)) {
$childs[] = $row[id];
}
$resultsFoundTextSingle = ’Die Suche nach "%s" ergab %d Ergebnis.’;
$resultsFoundTextMultiple = ’Die Suche nach "%s" ergab %d Ergebnisse.’;
Die Suche nach "2" ergab 0 Ergebnisse.
// $resultsPage [int] // The default behavior is to show the results on // the current page, but you may define the results // page any way you like. The priority is: // // 1- snippet variable - set in page template like this: // [[AjaxSearch? AS_landing=int]] // where int is the page id number of the page you want // your results on // 2- querystring variable AS_form // 3- variable set here // 4- use current page // // This is VERY handy when you want to put the search form in // a discrete and/or small place on your page- like a side // column, but don't want all your results to show up there! // Set to results page or leave 0 as default $resultsPage = 1;

)This discussion is closed to further replies. Keep calm and carry on.