We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25969
    • 118 Posts
    I’m trying to show a separate tertiary menu only for paths that need one using Wayfinder but I can’t suss it. Should I approach this from Wayfinder’s side or use UltimateParent in some way? I’ve tried using UltimateParent but it still returns a DocID even if the depth isn’t ’met’, I’d prefer -1 if the current document isn’t deep enough for the ’top’ parameter of UltimateParent.
      • 4172
      • 5,888 Posts
      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` ]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 25969
        • 118 Posts
        Thanks for that Bruno, I can work from that.