We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19598
    • 17 Posts
    Okay, what I’m trying to do is relatively simple, I imagine - I just have no idea on how to call upon it.
    I want, say I have a page called "Example", and then from that page sprout 5 child-pages, "1", "2" etc. - what I want is to call on all of the names of these pages into PHP, so I have an array of all of the pages titles.
    How do I retrieve this information?

    Cheers,
    Stephen
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      Have you looked at the Wayfinder or ListIndexer Snippets? They will list children of documents... or do you specifically need to do this within your own PHP code? If that’s the case, look at the MODx API: http://wiki.modxcms.com/index.php/Category:API
        • 19598
        • 17 Posts
        Yes, I do need it to come out in my PHP
        And that link you sent me was really helpful thanks smiley I found some code at http://wiki.modxcms.com/index.php/API:getDocumentChildren which I think is exactly what I want, but the article is a little stunted so I was wondering what I need to put in each variable.
        array getDocumentChildren($id=-1, $active=1, $deleted='0', $fields='id, pagetitle, description, alias, parent', $where, $sort, $direction, $limit);

        I imagine I only want $fields=’pagetitle’ so as to only have the pagetitle, but I’m not sure what I need to set $id, $active and $deleted to.. huh

        Thanks for your help laugh
          • 19598
          • 17 Posts
          That seems good.

          So could I, instead of documentIdentifier - put "Index", if the page were the index page? Or would it be "1", if it was the ~1~ page?

          Also, will the array come back as
          $docArray[1]=="IndexFirstChild";
          $docArray[2]=="IndexSecondChild";

          Yeah?
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            $modx->config[’site_start’] is how to access the "home" page in a snippet.
              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