We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27448
    • 17 Posts
    I’m trying to use a snippet that is called with the current document ID as an argument. It isn’t working properly, and I noticed the following. I have friendly alias paths enabled, but I was under the impression that a call for document 36979 like:

    index.php?q=36979

    ought to work regardless. However, it doesn’t. If I call

    index.php?q=journal/fj61/36979

    then that works, as does

    index.php?q=journal/fj61/article4.html

    Am I wrong that the document should be callable directly by the id without the paths? If not, is there an easy fix to the snippet so that it calls the current document even with FURL paths turned on?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      In snippet code, $modx->makeUrl(36979);

      In HTML (content or template or chunk) [~36979~]
        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
        • 27448
        • 17 Posts
        Thanks for the help. Do you know the answer to my first question -- Should the document still be callable directly by the id without the paths even with FURL paths on?
          • 7231
          • 4,205 Posts
          [~id~] will create the path according to the FURL settings. With FURL on the url will be index?id=123 with FURL on the same placeholder will output /path/alias.html

          This is the same way that $modx->makeurl(id) works inside a snippet. So rather than outputting the url directly, use the makeurl() function to do it for you and the path will be built accordingly.

          In snippet code, $modx->makeUrl(36979);
            [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]