I hope this is the right forum to post this.
I created a function for the DocumentParser class that you guys might find useful. It’s pretty simple; just a moderate modifation of the getActiveChildren class. It gets all of the active descendants of a page, and rather than placing them in some sort of hierarchical array, it just clumps them all together as if there were no hierarchy. This has been a necessary function for me on several occasions:
function getActiveDescendants($id=0, $sort='menuindex', $dir='ASC', $fields='id, pagetitle, description, parent, alias, menutitle') {
$tblsc = $this->getFullTableName("site_content");
$tbldg = $this->getFullTableName("document_groups");
// modify field names to use sc. table reference
$fieldsFormatted = 'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$fields)));
$sortFormatted = 'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$sort)));
// get document groups for current user
if($docgrp = $this->getUserDocGroups()) $docgrp = implode(",",$docgrp);
// build query
$access = ($this->isFrontend() ? "sc.privateweb=0":"1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").
(!$docgrp ? "":" OR dg.document_group IN ($docgrp)");
$sql = "SELECT DISTINCT $fieldsFormatted FROM $tblsc sc
LEFT JOIN $tbldg dg on dg.document = sc.id
WHERE sc.parent = '$id' AND sc.published=1 AND sc.deleted=0
AND ($access)
ORDER BY $sortFormatted $dir;";
$result = $this->dbQuery($sql);
$resourceArray = array();
for($i=0;$i<@$this->recordCount($result);$i++) {
array_push($resourceArray,@$this->fetchRow($result));
}
if(count($resourceArray) > 0) {
foreach($resourceArray as $resource) {
$newresource = $this->getActiveDescendants($resource['id'],$sort,$dir,$fields);
$resourceArray = array_merge($newresource,$resourceArray);
}
}
return $resourceArray;
}
I hope it helps. Also, let me know if there is an existing way to accomplish this that is simpler. Thanks alot.