We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17103
    • 5 Posts
    Hello everybody,
    I’m a MODx newbie (ver 0961p2) and I beg your pardon if I’m asking for elementary or simple questions.

    I’m trying to embedding snippets within snippets into a chunk, but MODx seems to solve only one of the two snippets.

    My code
    [!SnippetA?&param=`[[SnippetB? &param=`value`]]`!]


    In the final page it generates this:
    [!SnippetA?&param=`value_from_SnippetB`!]
    solving only SnippetB.

    I use this code in other templates, and it works correctly. I have a problem using it in a chunk only.
    It’s a known issue? Does exist a solution or a workaround?

    Thanks in advance for your help,

    Alessandro
      • 7231
      • 4,205 Posts
      Try using [[snippet]] for the outer snippet and [!snippet!] for the other one.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 17103
        • 5 Posts
        Thanx dev_cw, but I’ve already tried this. And many other combinations with the cacheable settings of the page containing the chunk.

        I’ve experimented the problem also with this call:
        [[Snippet?&param=`[*TV*]`]]

        It seems that my MODx solves only the inner snippet/TV (Ditto, UltimateParent, GetField and many others... I think it doesn’t depend on snippets...)

        Alessandro
          • 7231
          • 4,205 Posts
          I notice that there is no space between the ?& in your calls:
          [[Snippet?&param=`[*TV*]`]]
          In the example that you say gets the inside snippet there is a space in the inner call but not in the outer one. I am wondering if there needs to be a space between the ? &

          Give this a try and see if it helps. I always put a space out of habit so I don’t know if it is required.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 17103
            • 5 Posts
            It doesn’t work (also with spaces at the end or in the middle).
            You can use nested snippets into a chunk?
              • 17103
              • 5 Posts
              Eureka!
              Don’t ask me why or how I’ve discovered this - I’m a newbie - but... it works!

              My code in the chunk is:
              <img src="/assets/images/Manifesto_[[GetField? &docid=`[[UltimateParent? &topLevel=`2` ]] `]].jpg">

              The problem is that MODx resolves the inner snippet only (UltimateParent).
              But if I "let it makes its job", it seems that MODx memorizes the correct value of the inner snippet and elaborates the second one properly.

              So my final code is:
              <div style="display:none">[[UltimateParent? &topLevel=`2` ]]</div>
              <img src="/assets/images/Manifesto_[[GetField? &docid=`[[UltimateParent? &topLevel=`2` ]] `]].jpg">


              ... and it works.

              Greetings,
              Alessandro
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Did you try the nesting of the snippets with the outer snippet uncached [!...!] and the inner snippet cached [[...]]? This usually works, since the parser won’t process the uncached snippet on the first pass, process the inner cached snippet, then processes the outer snippet on the second pass, when the value of the inner snippet is now available.
                  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
                  • 7231
                  • 4,205 Posts
                  Glad you got it working, but this should have worked as well (as sottwell states):
                  [[GetField? &docid=`[!UltimateParent? &topLevel=`2` !]`]]
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 17103
                    • 5 Posts
                    Hi guys, thanks for your support.
                    I’ve tried your code but it doesn’t work. I’ve experimented the problem also with tv.
                    Do you think it’s a problem of my MODx configuration?

                    By the way, the chunk is doing its job... it’s an important aspect of the situation.

                    Bye,
                    Alessandro