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?¶m=`[[SnippetB? ¶m=`value`]]`!]
In the final page it generates this:
[!SnippetA?¶m=`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
Try using [[snippet]] for the outer snippet and [!snippet!] for the other one.
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?¶m=`[*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
It doesn’t work (also with spaces at the end or in the middle).
You can use nested snippets into a chunk?
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
-
☆ 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.
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