We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28173
    • 409 Posts
    Hi smiley

    I want to make a submenu with Wayfinder and the dropdowns system offered by the Bootstrap framework

    But to do this, I need to get the ID of the parent in the innerTpl template.

    Is there any way to get it with Wayfinder ?
    Something like wf.parent would be really helpfull smiley [ed. note: Spheerys last edited this post 13 years, 11 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I don't think you need that; Wayfinder by default automatically adds a classname of "active" in the current link as well as all of its parents.

      There is another property you can use to specifiy a classname for the current link itself if you need one that does not also get added to all all of its parents.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 28173
        • 409 Posts
        but I don't need a class name.
        I need to get the id of the parent of the submenu generated in innerTpl [ed. note: Spheerys last edited this post 13 years, 11 months ago.]
          • 28173
          • 409 Posts
          My WF call is like this :
                [[Wayfinder? 
                    &startId=`0` &level=`2` 
                    &outerTpl=`menuOuter` &outerClass=`nav` &rowTpl=`menuRow`
                    &innerTpl=`menuInner` &innerRowTpl=`menuInnerRow`
                ]]


          And now the templates used (sorry for the heavy code... it's the dropdowns fonction of Bootstrap...)

          * menuOuter :
          <ul[[+wf.classes]]>
          [[+wf.wrapper]]
          </ul>


          * menuRow :
            <li class="dropdown [[+wf.classnames]]"><a class="dropdown-toggle" id="label[[+wf.docid]]" role="button" data-toggle="dropdown" data-target="#" href="[[+wf.link]]">[[+wf.linktext]]<b class="caret"></b></a>
          [[+wf.wrapper]]</li>


          * menuInner :
          <ul class="dropdown-menu [[+wf.classnames]]" role="menu" aria-labelledby="label[[+wf.docid]]">
          [[+wf.wrapper]]
          </ul>


          * menuInnerRow :
            <li[[+wf.classes]]><a href="[[+wf.link]]">[[+wf.linktext]]</a>[[+wf.wrapper]]</li>



          The goal is to have on the result, the same id="label23" (in menuRow) and aria-labelledby="label23" (in menuInner). The number is for example.

          The easy and logical way to do this should to use a WF placeholder like this :
          [[+wf.parent]]

          ... but it doesn't exist !!!
          So I'm looking for an alternate way to have this result... [ed. note: Spheerys last edited this post 13 years, 11 months ago.]
            • 22427
            • 793 Posts
            You can create a Custom Output Filter - see
            http://rtfm.modx.com/display/revolution20/Custom+Output+Filter+Examples

            Try this:
            Write a snippet named "theparent":
            <?php
            //Output modifier  :theparent
            &res = $modx->getObject('modResource',$input);
            return $res->get('parent');

            Then where you would have put the desired [[+wf.parent]], write this:
            [[+wf.docid:theparent]]
            I couldn't test it, but that should do it.
              • 28173
              • 409 Posts
              You make a small mistake on the 3d line : &res instead of $res

              But it still doesn't work :
              <?php
              //Output modifier  :theparent
              $res = $modx->getObject('modResource',$input);
              return $res->get('parent');
              


              The result is the number zero, not the parent's id [ed. note: Spheerys last edited this post 13 years, 11 months ago.]
                • 22427
                • 793 Posts
                You make a small mistake on the 3d line : &res instead of $res
                I just wanted to test you... ;-))

                But it still doesn't work :

                May be you have to call the placeholder uncached:
                [[!+wf.docid:theparent]]


                  • 28173
                  • 409 Posts
                  I just wanted to test you... ;-))
                  Héhé smiley

                  May be you have to call the placeholder uncached:
                  I did it, but it always return 0 [ed. note: Spheerys last edited this post 13 years, 11 months ago.]
                    • 22427
                    • 793 Posts
                    I made a test: My modifier theparent works like intended, that is [[+wf.docid:theparent]] returns the ID of the parent of the resource with ID [[+wf.docid]].
                    So obviously it is something else to produce the 0 output.