We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29860
    • 59 Posts
    hi all

    I am having an issue where I am passing a template variable into a snippet with a call:

    [!createLink? &link=`[*jumpToLink*]`!]

    The [*jumpToLink*] is a url with query parameters and it gets trimmed at the point of these special characters.

    so for example:

    www.google.co.uk/search?q=testing+on+modx&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

    becomes
    http://www.google.co.uk/search

    so when I reference the parameter link in my example call, it is incorrect.
    i’ve tried using the text and url tv type but still no luck

    Is this a bug? Or am i missing something?
      • 10487 MODX Staff
      • 1,535 Posts
      Question marks and ampersands have special meanings to the document parser when parsing a snippet call in Evo - what is likely happening is that the parser is choking on that URL because it contains the special characters it expects to define the structure of the snippet call.

      If the TV is attached to the page, why not just pass in the TV name rather than the value and then grab the value from the $modx->documentObject array within the snippet. That will avoid the issue.

      Or, if you are manually entering the URL into the snippet call - you will need to have some kind of substitution for those characters, e.g.: |eq| for ’=’, |amp| for ’&’, |bt| for ’`’

      Then, in the CreateLink snippet do a str_replace() for each of those to put them back to what they need to be.
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 22303 MODX Staff
        • 10,725 Posts
        Unfortunately, MODx Evolution (0.9.x/1.x) does not support the characters ?, &, or = in the tag strings. This is why it is failing. You would be better off just passing the name of the TV, then get the value of that TV inside your snippet.

        FWIW, this is not/will not be an issue in the MODx Revolution releases.
          • 29860
          • 59 Posts
          omg!!!
          The more I learn about modx...the more amazing it is!
          I didnt know you can access the TV as well!

          As always, big thank you!