Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/styllloz/public_html/qa-include/qa-base.php on line 1175

Warning: session_start(): Cannot start session when headers already sent in /home/styllloz/public_html/qa-include/app/users.php on line 162

Warning: Cannot modify header information - headers already sent by (output started at /home/styllloz/public_html/qa-include/qa-base.php:1175) in /home/styllloz/public_html/qa-include/app/users.php on line 1267

Warning: Cannot modify header information - headers already sent by (output started at /home/styllloz/public_html/qa-include/qa-base.php:1175) in /home/styllloz/public_html/qa-include/app/page.php on line 356
MODX Revo: total number of extra resources? - code-flow.club | Q&A

MODX Revo: total number of extra resources?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
57 views
Continue to learn modx and pdoTools.
I have:
The father - The son 1 ---The grandson of 1 ---Grandchild 2 ---Grandson 3 ---Grandson 4 - The son 2 ---The grandson of 1 ---Grandchild 2 ---Grandson 3 ---Grandson 4 - The son 3 ---The grandson of 1 ---Grandchild 2 ---Grandson 3 ---Grandson 4


Number of sons and grandsons will grow naturally.
How to calculate and display the number only grandchildrenusing pdoTools or another plugin if it will not conflict with pdoTools (I just XS if possible) or system methods?

Now brought so for clarity:
[[pdoMenu? &parents=`19` &level=`0` &tpl=`@INLINE [[+children]]` &countChildren=`1` ]]


In the end I got:
1241


Everything works correctly, but to summarize them? In the end it turned out:
17
by | 57 views

2 Answers

0 like 0 dislike
One project is done. Keep.
Create a snippet. Name it, for example countGrandsons.
<?php\r$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);

In the chunk call something like this: [[!countGrandsons? &id=`[[+id]]`]].
In the parameter &id is necessary to specify the ID of the resource, grandchildren which you want to calculate.
by
0 like 0 dislike
Try this:

[[pdoResources? &parents=`19` &totalVar' => 'total', &depth = `10`, &where = $where ]]


where $where - coded json array with the conditions which you want to specify for the selection..for example, id of a template, published or not, etc.

And see the result in the placeholder [[+total]]
by

Related questions

0 like 0 dislike
2 answers
asked Aug 7, 2019 by blackseabreathe
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,181 users