We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16087
    • 12 Posts
    Does anyone happen to know an easy way to make the top level of the Wayfinder navigation have a unique class for each item? The following is an example of what I’m trying to accomplish:

    <ul>
    <li class="n1">Link</li>
    <li class="n2">Link</li>
    <li class="n3">Link</li>
    <li class="n4">Link
    <ul>
    <li>Link</li>
    <li>Link</li>
    </ul>
    </li>
    </ul>

    Any ideas? Thanks much.
      • 14050
      • 788 Posts
      In your rowTpl you could use [+wf.docid+]. That way each one would have a unique class name based on its unqiue document ID.
        Jesse R.
        Consider trying something new and extraordinary.
        Illinois Wine

        Have you considered donating to MODx lately?
        Donate now. Every contribution helps.
        • 4310
        • 2,310 Posts
        Adding to what Jesse R suggested,
        If you only want a unique id for parents create a chunk ParentRow:
        	<li class="n[+wf.docid+]">
        	<a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>
        	[+wf.wrapper+]
        	</li></ul>';

        and add it to your Wayfinder call :
        &parentRowTpl=`ParentRow`

        That should leave the children docs with no classes added.
        EDIT as per dev_cw
          • 7231
          • 4,205 Posts
          <li class="[+wf.docid+]">


          Question: can a class have a name beginning with a number? Should it be:

          <li class="n[+wf.docid+]">


          Maybe the method illustrated bellow is better:

          &rowIdPrefix
          default: FALSE
          values: name of prefix
          description: If this parameter is set, Wayfinder will replace the placeholder [+wf.id+] with a unique id consisting of the specified prefix plus the document id.
          example: &rowIdPrefix=`topMenu` will output the following for doc # 29: id="topMenu29"
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 16087
            • 12 Posts
            I tried it, and it appears to be working great, except that &parentRowTpl only works on folders/containers, and I have some weblinks and single documents in the main nav.

            I tried using &rowTpl, but that gave every list item a class, which I suppose isn’t the end of the world, just unnecessary.

            Or I could just make all of the main nav documents containers, but they won’t have any sub links. Any suggestions?

            Thanks for the help btw
              • 4310
              • 2,310 Posts
              I just make every top level item a container smiley
                • 7231
                • 4,205 Posts
                Or use rowTpl for the first level and then use a different innerRowTpl for the sub menus. You can have different template chunks (thus different structure) for the outer (top level) and the inner (sub levels) of the menu.

                Here is the whole set of available options:
                http://www.muddydogpaws.com/development/wayfinder/parameters.html
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 16087
                  • 12 Posts
                  Thanks everyone, I think both suggestions work great depending on the menu design.