We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    Hi,

    Hopefully someone can advise on the following.

    I'm trying to pass the value of [~id~] into a snippet. So for example
    [[mysnippet? &param=`[~[*id*]~]` ]]
    


    But it seems my snippet is running before the link tag is processed. I was wondering if there's a way to process the link tag within the snippet itself.

    I was going to use $modx->makeUrl method but this includes the full url (sub directories etc) which i don't want.

    I suppose i could strip out the base url from it but was hoping there was an easy option of processing the link tag.

    Edit:
    I'm using Evo 1.0.6

    Thanks

    Ben [ed. note: bennyb last edited this post 14 years, 5 months ago.]
      • 22427
      • 793 Posts
      May be it's just the typo? $param should be &param

      And you're sure you want to use Evo syntax?
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        You can also try making the snippet uncached so it gets processed later.
          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
          • 36926
          • 701 Posts
          Thanks for the replies,

          Ottogal yep just a typo there, i've amend post and yeah I'm using Evo.

          Susan, yep tried cached and uncached but still no luck.

          I've stripped the snippet down to the basics:

          [[mysnippet? &url=`[~[*id*]~]` ]]
          


          For this example the value of the url will be "en/home.html"
          The snippet code is:
          $pos = strpos($url, 'en');
          $output = $pos;
          return $output;
          


          This should return 0, but it's returning nothing at all.

          If I manually set &url in the snippet call it works fine. Also if I output $url in the snippet the correct url is returned. But I think all that is happening here is it's actually just outputting "[~[*id*]~]" again which is then getting processed outside of the snippet.

          Thanks again
          Ben



            • 36404
            • 307 Posts
            hi,

            i've got a little (and maybe silly smiley) question
            how do you expect modx to output en/something.html ? your ressources are in a en folder ?

            just because if you were using yams you url should be (yams_id)/[~[*if*]~]

            just wondering...

            have swing
              réfléchir avant d'agir