We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25357
    • 92 Posts
    I did search for half an hour in the Wiki and here, but can’t locate an answer. The links to potential documents I *did* find brought up that login screen for the documentation I can’t seem to get around with any login associated with modX.

    I’m rebuilding a site that was originally constucted in Evo 0.9 around 2005. smiley There is a custom snippet here using the following methods:

    getDocumentChildrenTVarOutput
    getChunk

    Are there equivalents for these in 2.+? (2.0.8)

    Would rather not rebuild the wheel if I can avoid it.
      • 22303 MODX Staff
      • 10,725 Posts
      getChunk is still perfectly valid.

      Documentation is being produced as we speak to detail how to go about replacing these methods in legacy code.
        • 25357
        • 92 Posts
        I thought getChunk might be, any methods I can sniff around in for the other? smiley
          • 25357
          • 92 Posts
          Well, it’s not pretty, and probably inefficient, but came up with a solution using getCollection and getObject.

          // $parents passed as a list of ID's and exploded.
          foreach($parents as $parent){
          	// get the children
          	$docs = $modx->getCollection('modResource',array(
              	'published' => 1,
          		'parent' => $parent
          	));
          	foreach ($docs as $child) {
          		$record['id'] = $child->get('id');
          		$record['alias'] = $child->get('alias');
          		$record['pagetitle'] = $child->get('pagetitle');
          		$obj = $modx->getObject('modResource',$record['id']);
          		// These are tv "names"
          		foreach ($tv_fields as $fld)  { $record[$fld]=$child->getTVValue($fld); }
          		array_push($result,$record);
          	}
          	//$result=array_merge($result,$modx->getDocumentChildrenTVarOutput($parent,'*'));
          }
          

            • 22303 MODX Staff
            • 10,725 Posts
            Actually, all you need is:
            <?php
            // $parents passed as a list of ID's and exploded.
            foreach($parents as $parent){
                // get the children
                $children = $modx->getCollection('modResource', array(
                    'published' => 1,
                    'parent' => $parent
                ));
                foreach ($children as $child) {
                    // These are tv "names"
                    $record = $child->toArray();
                    foreach ($tv_fields as $fld) {
                        $record[$fld]=$child->getTVValue($fld);
                    }
                    $result[] = $record;
                }
            }