Search code examples
modxmodx-revolution

MODX Revo getChildIds options


What is the $options parameter available for this method?

array getChildIds ([integer $id = null], [integer $depth = 10], [array $options = array()])

I am looking for a way to get all the children (depth=3) where the children's alias isn't "f".


Solution

  • Use this:

    <?php
    $id = 123;
    $depth = 3;
    
    $ids = $modx->getChildIds($id, $depth);
    $docs = $modx->getCollection('modResource', array(
        'id:IN' => $ids
        ,'alias:!=' => 'f'
    ));
    $output = '';
    foreach ($docs as $doc) {
        $output .= $doc->get('pagetitle') . '<br/>';
    }
    
    return $output;