We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15550
    • 12 Posts
    I have a snippet called `which_subnav` which works out the parent id of the current resource and returns the parent id.

    <?php
    // Snippet - which_subnav
    
    // Current document id
    $id = $modx->documentObject['id'];
    
    // Is current document a child or parent
    if ($modx->documentObject['isfolder'] == 0) { // Current document is a child - use it's parent's id
        $subnav_id = $modx->documentObject['parent'];
    }  else { // Current document is a parent - use it's id
        $subnav_id = $id;
    }
    
    // Return id to be used in by Wayfinder
    return $subnav_id;
    ?>
    


    This snippet is working correctly.

    I’m trying to use the id returned by this snippet as the startId parameter in Wayfinder but I can’t get it to work.

    This is the wayfinder snippet call.

    [[Wayfinder? &startId=`[!which_subnav!]`]]
    


    I’m just not getting any output from the wayfinder call - any ideas.

    note: If I enter an id instead of calling the which_subnav snippet it works fine.

      • 15550
      • 12 Posts
      Solved.

      The documentation tells you to use cacheable and non cachable alternating, should be the other way round.

      Also discovered that I could also use UltimateParent instead of my custom snippet.