All you want is the total of docs? You do not want to display any docs but just the total?
If this is what you want I can think of a slick way to get this by using Ditto to generate the doc list of a given parent and then transform the results into an array and then use the count() function to do the math and return a number.
This would be the snippet code:
<?php
// totalDocs
$parent = isset($parent) ? $parent : $modx -> documentObject['parent'];
$depth = isset($depth) ? $depth : "1";
$showPublishedOnly = isset($showPublishedOnly) ? $showPublishedOnly : "1";
$seeThruUnpub = isset($seeThruUnpub) ? $seeThruUnpub : "0";
$showInMenuOnly = isset($showInMenuOnly) ? $showInMenuOnly : "1";
// Use Ditto to generate document list
$documents = $modx->runSnippet("Ditto", array(
"parents" => $parent,
"display" => "all",
"depth" => $depth,
"showPublishedOnly" => $showPublishedOnly,
"seeThruUnpub" => $seeThruUnpub,
"showInMenuOnly" => $showInMenuOnly,
"tpl" => "@CODE [+id+]," ));
$documents = explode( ',', $documents);
$totalDocs = (count($documents) - 1);
return $totalDocs;
?>
And use it like this:
This container has [!countDocs? &parent=`0` !] documents
And the returned value will be the number of published not hidden documents in a given container.
Note: this has limited testing, you may need to adjust/add parameters to get the desired results. I had to reduce the count by one in order to get the right number, not sure why, maybe somone else could enlighten us.
Note2: To get the showPublishedOnly to work correctly you will need the latest Ditto beta release. Currently it will select only the published or unpublished docs, in the new relese it will also count the total of both pub and unpub docs.
Anyway, hope this works out.
Edit: you may be able to get the results using the getChildIds API function since it returns an array of ids for the children of a given doc. However it does not seem to have parameters for published or hidden documents. So IMO using Ditto will allow more flexibility.
http://wiki.modxcms.com/index.php/API:getChildIds