We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36924 ☆ A M B ☆
    • 298 Posts
    I wanted to display the same sidemenu on both parent and child resource so I wrote my script without any output results thus:

    [[!If?
       &subject=`[[*id]]`
       &operator=`inarray`
       &operand=`34,43`
    
       &then=`
    [[!Wayfinder?
      &startId=`[[*id]]`
      &outerTpl=`SideMenuOuter`
      &rowTpl=`SideMenuRow`
      &innerTpl=``
      &innerRowTpl=``
      &hereClass=`always`
      &firstClass=``
      &lastClass =``]]`
    
      &else=`
    [[!Wayfinder?
      &startId=`[[UltimateParent]]`
      &outerTpl=`SideMenuOuter`
      &rowTpl=`SideMenuRow`
      &innerTpl=``
      &innerRowTpl=``
      &hereClass=`always`
      &firstClass=``
      &lastClass =``]]`
    
    ]]


    In this case 34 and 43 are parent resources (with children within). Kindly advise.
      • 22427
      • 793 Posts
      Since all the other properties are equal for both of your Wayfinder calls, I would use the If call to determine just the startId:
      [[!Wayfinder?
          &startId=`
             [[!If?
                 &subject=`[[*id]]`
                 &operator=`inarray`
                 &operand=`34,43`
                 &then=`[[*id]]`
                 &else=`[[UltimateParent]]`
             ]]`
          &outerTpl=`SideMenuOuter`
          &rowTpl=`SideMenuRow`
          &innerTpl=``
          &innerRowTpl=``
          &hereClass=`always`
          &firstClass=``
          &lastClass =``
      ]]
      

      But this obviously will not solve your problem.
        • 36924 ☆ A M B ☆
        • 298 Posts
        Thanks Ottogal. The behavior of your code is the same whether parent resources (34 or 43) or their respective child resources. This is exactly the behavior required, only problem is I do not want it displayed the way it is now: displaying all the menus from Home to the very last (only indenting the child resources underneath the parent).

        The intended is to only show the links to child resources whether viewing the parent or child. So if you have parent (34 - About Us) with children (

        • 35 - Mission,
        • 36 Approach,
        • 37 - Principles
        ), the menu will turn out to be just Mission, Approach, and Principles (whether you are viewing resource 34 (About Us) or any of 35, 36, 37) [ed. note: ojchris last edited this post 12 years, 4 months ago.]
          • 36924 ☆ A M B ☆
          • 298 Posts
          It's clear now that the `inarray` operator is not the guy for this job. I need something that is mutually exclusive.
            • 36924 ☆ A M B ☆
            • 298 Posts
            Resolved this by using the AndIf snippet provided here: https://forums.modx.com/thread/?thread=32601&page=1

            Maybe useful to someone, here is my final Wayfinder call:

            [[!Wayfinder?
                &startId=`
                        [[!AndIf? 
                        &condition=`[[*id]] in_array 34,43` 
                        &operator=`OR` 
                        &then=`[[*id]]` 
                        &else=`[[*parent]]`
            ]]`
                &outerTpl=`SideMenuOuter`
                &rowTpl=`SideMenuRow`
                &innerTpl=``
                &innerRowTpl=``
                &hereClass=`always`
                &firstClass=``
                &lastClass =``
            ]]


            Thanks again to ottogal direction on a more professional and faster nested if statement.
              • 22427
              • 793 Posts
              Alternatively you could try using an Output Modifier (not tested):
              [[!Wayfinder?
                  &startId=`[[*id:isnot=`34`:and:isnot=`43`:then=`[[*parent]]`]]`
                  &outerTpl=`SideMenuOuter`
                  &rowTpl=`SideMenuRow`
                  &innerTpl=``
                  &innerRowTpl=``
                  &hereClass=`always`
                  &firstClass=``
                  &lastClass =``
              ]]
              ( Perhaps you need to add :else=`[[*id]]` ) [ed. note: ottogal last edited this post 12 years, 4 months ago.]