We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40088
    • 708 Posts
    I'm transferring a static menu over to pdoMenu. The only issue I'm having is generating an id for each link. Here's part of the static menu:

    <li><a href="/services/families.html" id="serv1">Families</a></li>
    <li><a href="/services/couples.html" id="serv2">Couples</a></li>


    As you can see each link has a unique id. I need to replicate this with pdoMenu. I assume I need to create a custom &tplInner then add the proper syntax to generate the id but I'm not sure what that would be.

    This question has been answered by sottwell. See the first response.

      Todd
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use the &rowIdPrefix=`serv` property in the snippet call. Then your tpl would look like this:
      <li><a href="[[+link]]" id="[[+id]]">[[+linktext]]</a></li>


      (edited - corrected the [[+id]] placeholder) [ed. note: sottwell last edited this post 12 years, 3 months ago.]
        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
        • 40088
        • 708 Posts
        Thanks Susan.

        I tried your suggestion. The generated menu link now has an id attached but the actual id is not being generated:

        <li><a href="services/families.html" id="[+id]"></a></li>
        <li><a href="services/couples.html" id="[+id]"></a></li>


        Snippet call:

        [[pdoMenu?
        &outerClass=`nav`
        &tplInner=`Menu`
        &parents=`2`
        &rowIdPrefix=`serv`
        ]]


        Revo 2.2.14 [ed. note: todd.b last edited this post 12 years, 3 months ago.]
          Todd
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Typo. That needs to be [[+id]]
            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
            • 40088
            • 708 Posts
            Thanks, the id now appears but it seems ‘&rowIdPrefix’ doesn't work.
              Todd
            • discuss.answer
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              How interesting. It works fine if you have the placeholder in the li tag rather than the a tag. You should be able to use it in the li tag, and change your CSS to "#serv1 a" instead of "#serv1".

              After some poking and experimenting, it appears that you need to use the wf. prefix with that placeholder. Just [[+id]] will produce the ID of the resource in the row (which makes sense since that is a perfectly valid resource field), and to get the ID with the prefix you need to use [[+wf.id]] (or whatever placeholder prefix you may have indicated in the &prefix property).
              [ed. note: sottwell last edited this post 12 years, 3 months ago.]
                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