We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5586
    • 8 Posts
    I know there has to be a way to do this. I’m trying to use a snippet call as a snippet parameter. Here is my snippet call:

    [[Ditto? &documents=`[!xref_doclist? &data=`[*xref_casestudies*]` !]` &tpl=`ditto_cs_logo` &randomize=`1` &display=`3`]]

    The snippet "xref_casestudies’ is working when called by itself. It returns a comma-separated list of document ID’s (i.e. 36,70,73,126,50,48).

    This snippet call results in a "Modx Parse Error.

    I also tried saving the value to a placeholder, but it wouldn’t accept the ph as a parameter either.

    What am I doing wrong?

    Thanks
      • 7231
      • 4,205 Posts
      I don’t see anything wrong. What is the output of the xref_doclist snippet? For this to work it needs to be a comma seperated list without the trailing comma like 1,2,3,4 - nevermind you already answered this grin

      You can try inverting the [[ and [! so that it is [! [[ ]] !] I can never remember which is the right way to do it.

      Also you could use a wrapper snippet to run these snippet in, this will eliminate the cache issues. A wrapper snippet is one that runs other snippets within one snippet.
        [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]
        • 4310
        • 2,310 Posts
        [*xref_casestudies*] is defined as a TV by having the [*xxxx*] fromat, a snippet would be [[xxxx]] (cached) or [!xxxx!] (uncached)
        If [*xref_casestudies*] is actually a snippet of code then you’d want [[xref_casestudies]] so as to alternate between cached and uncached in a nested snippet call.
          • 5586
          • 8 Posts
          Thanks for the reply. The [*xref_casestudies*] tv is needed by the xref_doclist to return the comma-separated list of document ids.

          Are you unable to nest a TV inside of a snippet call inside of another snippet call? Am I violating some ModX rule here?


          Thanks for the help. I’m amazed at how quickly folks respond here.

          Best regards!
          CD
            • 7231
            • 4,205 Posts
            Just to follow up, it is uncached outside and cached inside. So it should be [! [[ ]] !].

            Are you unable to nest a TV inside of a snippet call inside of another snippet call? Am I violating some ModX rule here?
            No rules violated here. You can definitely nest TV as well as any other placeholders in snippet calls. I think it is the cache order that is getting the error.
              [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]
              • 5586
              • 8 Posts
              You are correct! Thank you. It works as expected now. The wiki showed an example of a nested snippet call, and I was following that example.

              Thanks again!
                • 7231
                • 4,205 Posts
                The wiki showed an example of a nested snippet call, and I was following that example.
                Which wiki post, maybe we should fix that. wink
                  [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]