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

    This is probably a very stupid question, but I’m currently trying to call a snippet from a chunk and I’m having some problems.

    I’ve tried calling it like this:

    [!runSnippet(’tax’), [+net_price+]!]

    and like this:

    [[runSnippet(’tax’), [+net_price+]]]

    where [+net_price+] is a variable I want to pass it.

    It goes to a very simple snippet that should print out test on the webpage, but currently isn’t.

    Any help would be appreciated!

    Thanks

    Hollie
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I presume you’re using Evolution (1.0.4)

      Snippet parameters take the form
      [!snippetname? &paramname1=`value1` &paramname2=`value2`!]
      

      Note that those are backticks, not single-quotes or apostrophes.

      http://sottwell.com/how-snippets-work.html
        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
        • 12294
        • 30 Posts
        Hi,

        I tried this, putting in the following:

        [!tax!]

        and then I tried,

        [!tax?!]

        and then lastly,

        [!tax? &paramname1=`[+price_net+]`!]

        but both caused the following syntax error:
        SQL Query error: INSERT INTO `modxshop`.`xshop_event_log` (eventid,type,createdon,source,description,user) VALUES(1,3,1289493853,’tax - Snippet’,’syntax error, unexpected \’[\’

        These are the only square brackets on the page - so I’m a little confused. If I was calling a snippet without parameters, would I do it as shown in the first example, or am I making another mistake there?

        Thanks again!

        Hollie
          • 12294
          • 30 Posts
          Managed to solve it sorry! The error was coming from my snippet - so thank you Susan for your help!

          :)