We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    If I try
    $docArray = $modx->getCollection('modResource',array(
        'parent' => 3,
        'published' => 1,
        'hidemenu' => 0
    ));

    and I print_r the results, I get this absolutely appalling array of objects in return, consisting of 157,858 lines, with the entire site's alias maps and cached elements, as well as 156 lines consisting of *RECURSION*, whatever that may mean! All to simply get a collection which I would expect to consist of four resource objects???

    How can I go about getting the IDs of the children of #3 that fit certain criteria, without this kind of outrageous bloat?

    This question has been answered by sottwell. See the first response.

      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
    • discuss.answer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Ok, getChildIds(...) is what I want.

      Turns out getChildIDs alone doesn't do what I want; a StackOverflow response let me to this, giving me a list of resources not showing in menus like My Resources, Your Resources, Our Resources, ...
      <?php
      $array_ids = $modx->getChildIds(3, 2, array('context' => 'web',));
      
      $docs = $modx->getCollection('modResource', array(
          'id:IN' => $array_ids
          ,'hidemenu: =' => 1
          ,'pagetitle: LIKE' => '%Resources'
      ));
      
      foreach ($docs as $doc) {
          $output .= $doc->get('pagetitle') . '<br/>';
      }
      
      return $output;
      [ed. note: sottwell last edited this post 13 years ago.]
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org