Действительно, в коде была ошибка:
<?php
$docid = isset($docid) ? intval($docid) : $modx->documentIdentifier;
$depth = isset($depth) ? intval($depth) : 0;
$isfolder = isset($isfolder) ? intval($isfolder): 0;
$tpl = isset($tpl) ? $tpl: -1;
$published = isset($published) ? intval($published): 1;
$davailable = $modx->getChildIds($docid, $depth);
if ($davailable){
$where = ($tpl > 0) ? 'template='.$tpl : 'isfolder='.$isfolder;
$dcount = $modx->getDocuments($davailable, $published, 0, 'id', $where);
return count($dcount);
}
return 0;
?>