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

    Firstly my apologies if my question isn’t that obvious at first.

    I’m trying to call a snippet, but instead of giving it a set of fixed parameters, I would like to set one of the parameters as a variable.

    SO, for example let’s say I’m using a gallery snippet that looks in the contents of a directory to generate thumbnails and images. The snippet asks for the location of the directory in a parameter. I don’t want this to be a fixed location, I would rather it reflected something about the user’s session. Specifically, the user’s ID.

    This way, a different gallery can be shown depending on the user logged in... without having to create pages manually for each user.

    I’d LOVE to hear any pointers how to do that kind of thing!

    Thanks

    Mat
      • 27708 MODX Staff
      • 2,502 Posts
      Snippet parameters are variables so you can set the parameter in the snippet either by retrieving the webuser id or a GET variable or any other variable. The only difference is that the parameter variable only gets defined in the snippet code rather than in the call.

      <?php 
      $myParameter = $modx->getLoginUserID();
      


      I am sure someone else might be able to shed much more light on this by hope this helps some.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 11887
        • 34 Posts
        Quote from: smashingred at May 16, 2010, 08:54 PM

        I am sure someone else might be able to shed much more light on this by hope this helps some.

        Nono - that’s perfect, I understand now. Thanks!
          • 27708 MODX Staff
          • 2,502 Posts
          Glad to hear it is what you needed. Feel free to share your results w/ the community.

          Cheers,

          Jay
            Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub