Answer the question
In order to leave comments, you need to log in
MODX Revo displaying the total number of additional resources?
I continue to study modx and pdoTools.
I have:
-Отец
--Сын 1
---Внук 1
---Внук 2
---Внук 3
---Внук 4
--Сын 2
---Внук 1
---Внук 2
---Внук 3
---Внук 4
--Сын 3
---Внук 1
---Внук 2
---Внук 3
---Внук 4
<div class="countChildren">12</div>
<div class="countChildren">4</div>
<div class="countChildren">1</div>
<div class="countChildren">17</div>
Answer the question
In order to leave comments, you need to log in
I did this for one project. Hold.
Create a snippet. Name it, for example countGrandsons .
<?php
$id=$modx->getOption('id',$scriptProperties,0);
$c = $modx->newQuery('modResource');
$c->where(array(
'published' => true,
'deleted' => false,
'isfolder' => false
));
$children = $modx->getChildIds($id);
if (count($children) > 0) {
$c->where(array(
'id:IN' => $children,
));
} else {
$c = 0;
};
$resources = $modx->getCollection('modResource',$c);
return count($resources);
. Try like this:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question