We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36695
    • 47 Posts
    Hi,
    I may be missing something obvious (usually the case...), but if I do this inside a chunk, which is called using myChunk?myVar=`valueneeded`:

    [[!mySnippet? &myVar=`[[+someplaceholder]]`]]


    The myVar value is empty when I try and use it in mySnippet.

    However, if I add another instance of the placeholder outside of the snippet call then it seems to work (i.e. myVar has the value of the placeholder when I use it in the snippet):

    [[!mySnippet? &myVar=`[[+someplaceholder]]`]] [[+someplaceholder]]


    Obviously I don’t want to output the additional placeholder in the chunk, but at the moment it’s the only way I can get snippet calls like this to work.

    Any advice welcome.

    Edit: This only happens when the snippet call is uncached.

    MODX 2.1.1-pl
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Is the placeholder being set in mySnippet? If that is the case, then the placeholder isn’t set when the snippet is run, so it won’t have any value.
        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
        • 36695
        • 47 Posts
        Thanks for your reply Susan,

        No, the placeholder isn’t set by the snippet. Actually, I may have used the wrong language: the value "myValue" is set with a property from a chunk call. So, for completeness:

        In a document (cacheable), I have the following chunk call:

        [[$TestChunk?mypropertyvalue=`SomeValue`]]


        In TestChunk chunk I have:

        [[!TestSnippet? &mypropertyvalue=`[[+mypropertyvalue]]`]]


        In TestSnippet I try and access "$mypropertyvalue", either directly or through $scriptProperties

        var_dump($scriptProperties);
        //Actually, when this is rendered the placeholder gets replaced onscreen, so I do something like
        $letters = str_split($mypropertyvalue,1);
        foreach($letters as $letter) echo $letter." ";
        //Outputs: [ [ + t e s t v a l u e ] ]
        // Would expect $mypropertvalue to equal "SomeValue" here
        


        When the snippet is called cached in the chunk it works OK (but for the real implementation I need it to be uncached).

        I have tried it with all tags being called uncached too (e.g. the initial chunk call, the "mypropertyvalue" property placeholder in the chunk, and the TestSnippet snippet call).
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Ah. Revo properties. I don’t work with Revo, so that’s outside of my field of knowledge.
            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
            • 22303 MODX Staff
            • 10,725 Posts
            You are overriding the value of the placeholder being set from the Chunk property in the Snippet call. Don’t do that! wink It would work if you used different placeholder names.