Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@morozVA
Created January 3, 2018 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morozVA/862006ba1e8374668994a7d9345f9e05 to your computer and use it in GitHub Desktop.
Save morozVA/862006ba1e8374668994a7d9345f9e05 to your computer and use it in GitHub Desktop.
evo ChildCounter
/***********************Как вывести количество документов в папке?*********************/
[[ChildCounter? &docid=`406` &depth=`2` &tpl=`15` &published=`0` &isfolder=`0`]]
&dicId - ID сканируемой папки
&depth - глубина сканирования
&isfolder - Если 1 - вернёт количество папок, если 0 - количество документов НЕ папок. Значения 0 или 1. По умолчанию 0.
&published - Если 0 - вернёт количество неопубликованных документов, если 1 - количество опубликованных документов. Значения 0 или 1. По умолчанию 1.
&tpl - если указан, то возвращает количество документов с шаблоном id которого равен &tpl
<?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;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment