We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5518
    • 28 Posts
    Is there any modx->config or related that gives the current link that the user is on?
      • 3749
      • 24,544 Posts
      I’m confused by your terms because a link is something you click on to get to another page so there’s no "current link" that the user could be on, unless you mean a link that the mouse is hovering over (in which case you’d probably use javascript to do what you want).

      It’s also not clear whether you want the document ID or the current URL or whether you want this for use in a snippet, a chunk, as an argument in a snippet call, or in some document’s content. It’s important because you might use different methods depending on where you are.

      I don’t mean to sound critical -- just trying to clarify things.

      For the current document’s ID number, you can use the MODx tag:

      [*id*]


      For the current URL, you can combine that with the link tag:

      [~[*id*]~]


      Try one of those and see if it gets you what you want.  smiley

      Hope this helps.




        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
        • 20288
        • 132 Posts
        Do you mean this in context of navigation having a different visual look than the rest of the navigation?
          • 7231
          • 4,205 Posts
          Wayfinder has built in features to highlight the current document. If you are using your own logic for the menu then you need to do an if statement to identify if you are in the current page by comparing the current doc (modx->documentIdentifier) with the doc id for the menu item. Need to understand better what you are after to be able to offer a better solution grin
            [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]
            • 5518
            • 28 Posts
            What I meant was, the url that the user is on atm when he or she is on the page.

            Such as http://www.google.com

            I found a way through PHP $_SERVER[’REQUEST_URI’]

            I was just wondering if ModX had a similar ability... Anyhow thanks for the help.
              • 3749
              • 24,544 Posts
              Here’s one way:

              $currentUrl = $modx->makeUrl($modx->documentIdentifier,"","","full");


              or to break it down:

              $id = $modx->documentIdentifier;
              
              $currentUrl = $modx->makeUrl($id, "", "", "full");


              If you don’t need the full url, you can just use:

              $currentUrl = $modx->makeUrl($id);
                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