Search code examples
modxmodx-revolutiongetresource

ModX: getResources from document and documents children


I want to use getResources to get the content from a document, and its child documents. I believe I can used &depth to do this but I cannot seem to get it working.

I have tried 2 approaches:

echo "[[!getResources?  $parents=`15`  &includeTVs=`1` &resources=`" . $resid . "` &depth=`1` &tpl=`tendertmp`]]";

and:

echo "[[!getResources? $parents=`" . $resid . "` &depth=`1` &includeTVs=`1` &tpl=`tendertmp`]]";

$resid is just a number generated by a snippet - the first example works fine without depth.

Would anyone know the correct way of using depth or a way to get the reources content along with its child resources content?


Solution

  • Why you do not use http://rtfm.modx.com/display/revolution20/modX.runSnippet ?

    $output = $modx->runSnippet('getResources',array(
       'parents' => $resid,
       'depth' => '1',
       'includeTVs' => '1',
       'tpl' => 'tendertmp'
    ));
    echo $output;
    

    and your second mistake in $parents instead &parents.