We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32911
    • 13 Posts
    I know I sound like a noob (that may be because I am...) but I have come back to a modx site that I am working on and hit a hurdle.

    I want to create a unique id (say id="selected") when the page is being viewed within the [[nav snippet]], I have not used wayfinder to create the nav it has been hard coded using [~page id~] can anyone point me in the right direction.

    As you can all guess this is simply to highlight the nav location using CSS, it was a client request post build and I don’t feel like totally recreating the [[nav snippet]] using wayfinder because the client has made so many changes I think that it would be a nightmare.

    Thanks in advance
    SW
      • 7231
      • 4,205 Posts
      I think you will get better help if you post the code to the "nav snippet" since I am not sure how that works. In any case to accomplish this you need to do some logic to identify the current document as well as identify it in the menu in order to add the style information. Depending on the snippet code a simple if() statement will handle that.

      Wayfinder will add the selected class automatically. Have you tried using Wayfinder?
        [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't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 3749
        • 24,544 Posts
        I don’t have a specific answer for you, but I can say that whenever I’ve converted an existing PHP menu to Wayfinder, I’ve been really glad I did it. smiley

        This is especially true for sites where the client makes a lot of changes.


          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 32911
          • 13 Posts
          Thanks for the replies. I am about to start work on this project again so if anyone has any further tips it would be fantastic and much appreciated.