We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6437
    • 157 Posts
    Hi all,

    I can’t seem to get the getDocumentChildren API call to work, was hoping someone could enlighten me as to what I’m doing wrong?

    Call from within snippet:

    [tt]$Categories = modx -> getDocumentChildren($id=20, $active=1, $deleted=’0’, $fields=’id, pagetitle, description, alias, parent’);[/tt]

    As far as i can see this is as close to the call contained in the api documentation as i can get to but the line throws up the following error

    [tt]Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\sokkit\site\modx\manager\includes\document.parser.class.inc.php(733) : eval()’d code on line 2[/tt]

    Being new to PHP I’m sure that I’m doing something fundamental wrong, but I’ve attemped using similar applications to those I’ve found when searching the forum to no avail.

    Any help would be appreciated.

    Ta

    Steve

    Addional problem detailed below solved @ http://modxcms.com/forums/index.php/topic,9246.0.html
      • 24414
      • 45 Posts
      You may want to have a look at this for some inspiration:

      FirstChild Snippet
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: DangerMouse1981 at Nov 15, 2006, 06:07 PM

        [tt]$Categories = modx -> getDocumentChildren($id=20, $active=1, $deleted=’0’, $fields=’id, pagetitle, description, alias, parent’);[/tt]
        It should be:
        $Categories = $modx->getDocumentChildren(20, 1, 0, 'id, pagetitle, description, alias, parent');

        you can’t have spaces between an object ($modx) and a function you are calling on that object (getDocumentChildren) using the object operator ( -> ).
          • 6437
          • 157 Posts
          Thanks for the replies both, the call now seems to work, a few simple errors seemed to cause alot of problems smiley

          Forgive my nievity but I’m calling a very simple function I’ve created using getDocumentChildren() from eForm and placing the output into a placeholder and am now getting the following error - once again refering to the line with the getDocumentChildren call.

          [tt]Fatal error: Call to a member function getDocumentChildren() on a non-object in C:\sokkit\site\modx\manager\includes\document.parser.class.inc.php(733) : eval()’d code on line 9[/tt]

          The function is called by [tt]getCategories(&$fields);[/tt] which allows me to add the function output to an eForm template. Could the conflict be in the fact that i have an array called [tt]$fields[/tt] in the function call and [tt]getDocumentChildren()[/tt] takes a paramater called [tt]$fields [/tt] ?

          The full code has actually been tested away from eForm and outside the "function wrapper" and it works as anticipated, with the same [tt]getDocumentChildren()[/tt] call causing no errors.

          If this is completely stupid please feel free to tell me to shut up, but any advice would be appreciated smiley

          Thanks again

          Steve