Skip to content

Instantly share code, notes, and snippets.

@bwente
Last active October 19, 2016 11:43
Show Gist options
  • Save bwente/f7bc3b86136b0de2aae6 to your computer and use it in GitHub Desktop.
Save bwente/f7bc3b86136b0de2aae6 to your computer and use it in GitHub Desktop.
Count the children from a parent.
<?php
// [[getChildCount? &parent=`[[+id]]`]]
$count = 0;
$parent = isset($parent) ? (integer) $parent : 0;
if ($parent > 0) {
$criteria = array(
'parent' => $parent,
'deleted' => false,
'published' => true,
);
$count = $modx->getCount('modResource', $criteria);
}
return (string) $count;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment