you can try this, where you can set chunks depending on level:
<?php
//use it in the call like this:
//
//[[GetChunkByLevel? &chunks=`,,,@CODE<h4>Aufgaben:</h4>,@CODE<h4>Subaufgaben:</h4>` &debug=`0` ]]
//[[GetChunkByLevel? &chunks=`chunk0,chunk1,chunk3,projectlist,projectlist` &debug=`0` ]]
$chunks_arr = (isset($chunks))? explode(",",$chunks) : array(); // [ array ]
$debug = (isset($debug))? $debug :0;
$current_level = ( count( $modx->getParentIds( $modx->documentObject['id'] ) )+1 );// von Stefan
$output=$chunks_arr[$current_level];
if ($debug == '1'){
echo 'current_level '.$current_level.' ';
echo 'chunk '.$output;
}
if (substr($output,0,5) == '@CODE'){
$output = trim(substr($output,5));
}
else {
$output= "{{".$output."}}";
}
return $output;
?>
Examples:
[[GetChunkByLevel? &chunks=`,,,@CODE<h4>Aufgaben:</h4>,@CODE<h4>Subaufgaben:</h4>` &debug=`0` ]]
[[GetChunkByLevel? &chunks=`chunk0,chunk1,chunk3,projectlist,projectlist` &debug=`0` ]]