Spent a long time on this last night and I figure it’s time to call for some assistance. I know everyone says this, but it sure looks like it should work. I’m trying to provide for two different calls to Wayfinder: if the current document is at level 1, then call Wayfinder with startId set to [*id*], or if the current document is at level 2, then set startId to [*parent*]. I start with a snippet in the template:
[[hasChildren? &noChildChunk=`noKidsSubMenu` &childChunk=`foundKidsSubMenu`]]
I’m using this snippet from Taff. If the document has children, then it inserts the chunk that displays a submenu. Here is the foundKidsSubMenu:
<div id="subnav-wrapper">
<div id="subnav-wrapper-2">
<div class="center-wrapper">
<div id="subnav">
[[Wayfinder? startId=`[!wfStartid!]` &level=`2` &outerClass=`tabbed` &hereClass=`current_page_item`]]
<div class="clearer"> </div>
</div>
</div>
</div>
</div>
The main line is the Wayfinder call. For the startId, I use the snippet wfStartid, which looks liks this:
<?php
$parent = $modx->documentObject['parent'];
$id = $modx->documentObject['id'];
if($parent == 0) return $id;
return $parent;
?>
If the document’s parent is 0, then return the document ID, otherwise return its parent’s ID. Everything seems to work separately, but not all together. The problem seems to be in using the snippet as the startId argument to Wayfinder. I can put [!wfStartid!] by itself in the chunk and it displays the proper values. I can put a number in for the startId and it works fine. The two just aren’t working together. Am I just nesting too much? A snippet as a snippet argument in a chunk in a snippet? I’m sure there are other ways to do this and it’s almost guaranteed there are better ways to do it, but I’m just learning MODx and would appreciate a gentle nudge. Thanks.