We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38060
    • 29 Posts
    I encountered, that the JavaScript code

    !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');


    was breaking my pages on the CMS level after updating to 1.0.12. I do not know if this is a MODx issue, or if this has to do with snippets or pug-ins I run. However, I fixed it this way:

    1. I created a blank HTML document outside of MODx, where I encoded the JavaScroipt using

    escape("!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');")


    2. Then I embedded the generated code, unescaped it and executed it

    eval(unescape("HEREGOESTHEESCAPEDCODE'));
    


      • 7327
      • 195 Posts
      Yeah it looks like a bug or some kind of limitation. Encountered that too. Here's what I noticed about this particular problem:

      The following will break the site:

      If X Template...
      - Uses ANY chunk: {{chunk_name}}
      - Has Twitter code that was pasted raw within the template

      However, the following works:

      If X Template...
      - Uses ANY chunk: {{chunk_name}}
      - The Twitter code is within a chunk used within the template: {{twitter_chunk}}

      • }} is maybe detected as closing chunk tag in the javascript code above. That could confuse the parser somehow. Replacing it by } } should solve the issue.
          • 7327
          • 195 Posts
          @Jako - yeah, that seems to be issue all right. Tried the change and it now works (raw code on template level). [ed. note: diatomin last edited this post 10 years, 5 months ago.]
            • 38784
            • 1 Posts
            Hi all!

            Firstly, after over two years of building numerous MODx sites, this is the first time I've had to actually post in the forum, as I've learnt, if you look, the answers are always out there for this brilliant CMS.

            @Jako, I've come across the same }} problem with WuFoo form code. The WuFoo Javascript embed has the following code in it: "catch (e) {}};" which escapes/closes the chunk and breaks the whole template.

            Unfortunately I have many users adding these forms, and I don't have complete control over what they add and train them how to add it (eg. look for the double }} and add a space between). In MODx 1.0.5 - 1.0.10 this is fine, it just appears to be the latest version, 1.0.12, that does this.

            Would really love to get this fixed (a pointer where to fix in the code is fine) so that I can continue upgrading all the sites to the awesome new Evo version, I really, really like the recent evolutions of MODx Evolution smiley