We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49680
    • 19 Posts
    I tried Bobray's code again, and this time it works!
    It might have been a missing ; as sottwell suggested anyway.

    Thank you very much!
      • 3749
      • 24,544 Posts
      You're welcome. wink

      FYI, the reason getParentIds() didn't work is that it doesn't accept a typical MODX 'where' array. The second argument is depth and the third is an array of options. The only option getParentIds() responds to is 'context'.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 49680
        • 19 Posts
        Hello again

        I am working now with Bobrays code, and I have a new question related to this, so I keep it in the same thread.

        It is about the order of the children.

        I have children with the ID's 11,12,13,14,15,16,17,18, 19

        Bobray's code returns: 14,15,16,11,13,12,17,18,19

        I have tried to change their order in the file-tree, but this does not change the output.

        I would very much like to reflect the file-tree order in my snippet-output.

        Is that possible and how?

        All the best
          • 4172
          • 5,888 Posts
          if you are talking about the order in the resource-tree, this is ordered by menuindex.

          Try this:

          $parentDoc = $modx->getObject('modResource', 5);
           
          if ($parentDoc) {
              $c = $modx->newQuery('modResource');
              $c->where(array(
                  'published' => 1,
                  'searchable' => 1,
                  'deleted' => 0,
              ));
              $c->sortby('menuindex');
              $children = $parentDoc->getMany('Children', $c);
           
              foreach ($children as $child) {
                  $output .= $child->get('pagetitle');
              }
          } else {
              $output = 'Parent not found';
          }
          return $output;
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 49680
            • 19 Posts
            Yes, thank you very much!