On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • How does the new API function getDocumentChildrenTVars work?

    Am trying to return the regular and TV fields for the children of a folder
    This and every other variation I have tried don't seem to return anything
    $thisid = $etomite->documentIdentifier;
    $children = $etomite->getDocumentChildrenTVars($thisid,"thumb");  $childrenCount = count($children);
    $child .= "<ol>";
    for($x=0; $x<$childrenCount; $x++) {
    $child .= "<li>".$children[$x]['id']." - ".$children[$x]['pagetitle']." - ".$children[$x]['description']." - ".$children[$x]['thumb']."<li>";
    $child .= "</ol>";
    return $child;

    thumb is a TV

    I don't speak php very well so I am probably on the wrong track any guidance would be great :?
    • Hi

      Here's how it should be used:

      Returns a two-dimensional array containing the selected TVs of all the children of the document specified.

      getDocumentChildrenTVars($parentid=0, $tvidnames=array(), $published=1, $docsort="menuindex", $docsortdir="ASC", $tvfields="*", $tvsort="rank", $tvsortdir="ASC")

      // get all the children of document id 10
      $result = $etomite-> getDocumentChildrenTVars (10,array(“id”,”pagetitle”));
      for ($i=0;$i<count($result);$i++) {
      	echo $result[$i][0][“name”]. “ = ” . $result[$i][0][“value”];
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
      • Thanks Raymond I get it now smiley