I have to generate some JavaScript code in my layout. I do it in my snippiet by placeholder:
[....]
$modx->setPlaceholder(’my_content’, $my_var->getPart(’content’));
Problem is that $my_var->getPart(’content’) in placeholder is broken in places when double bracked is used "[[" (this fragment of code is cutted)
I guess that there is any conflict in snippet when script try to generate double bracket what ModX use to set snippet name.
What can I do to fix it? When I do it out of MODX in clean PHP it works fine.
-
☆ A M B ☆
- 2,475 Posts
It sounds like you’re trying to nest Snippets... one executes and generates a [[place_holder]], and then you’re expecting to run the Snippet referenced by that new placeholder... I don’t think that will work. At least, it’s a risky design... you end up relying heavily on precise execution order. I know you can use "{{chunk_name}}" as a value for a template variable, and the template variable get substituted first, and then the chunk is substituted second.
Is there some other way for you to get the results you want without daisy-chaining Snippet names? In short, is there a way to get what you want without a Snippet outputting the name of another Snippet?
placeholder ’my_content’ generate JavaScript code like :
"var dArr = [[’Monday’,[[’TH’,’Thursday’],......etc"
it is third party JS code. Is it possible that MODx don’t like this brackets? How can I put this code to chunk rather than placeholder? I can’t find it in doc.
-
☆ A M B ☆
- 2,475 Posts
Well, I can think of 2 options:
1. Change the placeholders in the Javascript from the default.
2. Change the placeholders in MODx from the default.
I think #2 would involve hacking the core... you could alter the core so that it would look for some other demarcator for placeholders, e.g. [%this%].
If the Javascript library is well documented you might be able to change its placeholders... I don’t think [[ stuff is native javascript anything... it’s not like Perl where a "[ something ]" indicates an anonymous array...
I think the brackets are parsed out because modx thinks they are snippets (anything with [[ or [! is a snippet to modx and {{ a chunk and so forth..). I would put the javascript in a .js file and link it to the template.