Last active
October 19, 2016 11:43
-
-
Save bwente/f7bc3b86136b0de2aae6 to your computer and use it in GitHub Desktop.
Count the children from a parent.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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