Функция возвращает список всех дочерних узлов для pidInList в CONTENT
Код:
smCntnt = CONTENT
smCntnt{
table = smTable
select{
pidInList.cObject = USER
pidInList.cObject{
userFunc = user_commonfuns->childNodes
}
}
}
PHP код:
class user_commonfuns extends tslib_pibase{
//getChilds properties
var $uidList = array();
var $uidCheckList = array();
function arrayToCommaList($arr,$sep = ","){
foreach ($arr as $v){
$result .= $v.",";
}
$result = rtrim($result,",");
return $result;
}
//Call from TS user_commonfuns->childNodes
function childNodes($conf,$content){
global $TSFE;
$this->uidCheckList[] = $TSFE->id;
$this->getChilds();
return $this->arrayToCommaList($this->uidList);
}
function getChilds(){
$curUid = array_pop($this->uidCheckList);
$this->uidList[] = $curUid;
$query = "SELECT uid FROM pages WHERE pid = ".$curUid." AND deleted <> 1 AND hidden <> 1";
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)){
$tempUids[] = $row['uid'];
$this->uidCheckList[] = $row['uid'];
}
if(count($this->uidCheckList) != 0){
$this->getChilds();
}
}
}