Quote from: sottwell at Jul 18, 2009, 07:15 AM
Nested snippets have to be called the other way; the outer snippet uncached and the inner snippet cached.
This is because the snippets are processed as they are found, so the outer snippet will get processed before the inner one, so the parameter is not yet available to the outer one. If it’s called uncached, it doesn’t get processed right away (its tags get converted to cached tags on this pass through the parser), while the inner one will. On the next pass through the parser, the outer snippet now gets processed, and since the inner one was processed earlier, the proper parameter value is now available as the outer snippet is evaluated.
The other way to handle this would be to use $modx->runSnippet() in the major snippet to evaluate the other snippet.
It might also work to call the second snippet before the major snippet if the second snippet’s output were stored as a placeholder via $modx->setPlaceholder, and use that placeholder in your chunk.
You could also just make the code of the second snippet a function in the first one; remember that you must declare $modx as a global in functions.
thanks for the info, susan.
just to be clear. are you referring to my original problem? meaning that I will have to correct and make an uncached call of MajorSnippet and my template will have a cached call for TheOtherSnippet. Like so...
[!MajorSnippet &tpl=`tplWithAnotherSnippetCall`!]
tplWithAnotherSnippetCall is a chunk with the following contents:
Name:[+name+]
Profession:[+profession+]
Subscription Choices:
[[TheOtherSnippet]]
OR
were you talking about this one:
[[MajorSnippet &tpl=`[!TheOtherSnippet!]`]]
Though I havent implemented it yet(sigh...), according to u it should be [!MajorSnippet &tpl=`[[TheOtherSnippet]]`!]
I guess they were both wrong,either way
I was just getting into the runSnippet() alternative.hopefully it or one of them will work.
setPlaceholder hadnt worked. I had used it initially, but it wouldnt output anything. I posted a question on it yesterday
http://modxcms.com/forums/index.php/topic,37749.0.html I had made the call before the Major snippet, but nothing showed. Just cant remember whether I had done the caching arrangements well.
Will think about it and work it through. Hopefully I will solve it. Its been a bit painful but I’ve learnt alot on modx.