We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21872
    • 95 Posts
    I’m confused about static resources. According to http://rtfm.modx.com/display/revolution20/Static+Resource
    They behave exactly like a Document (standard Resource). Content within a Static Resource is parsed and displayed in the exact same way as a Document.
    Reading this, it sounds like a way of storing resources outside of the DB but parsing their content at runtime.

    One convention I always follow is to put all javascript in a file called global.js. After adding this file as a static resource, I created a chunk called TEST containing a string of text, "testing 1 2 3" and added an alert to global.js
    alert('[[$TEST]]');
    The alert that pops up says "[[$TEST]]" so the file is not being parsed. What does TFM mean when it says "Content within a Static Resource is parsed and displayed in the exact same way as a Document" ?

    Thanks.
      • 22303 MODX Staff
      • 10,725 Posts
      I assume you are accessing the Resource URL and not the actual file on the filesystem via the web server huh
        • 21872
        • 95 Posts
        Err. Oh. I had a file on the webserver that was at /js/global.js and made a static resource with a url of /js/global.js ... was that stupid? What should I do?
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: nsfdev at Dec 06, 2010, 08:47 PM

          Err. Oh. I had a file on the webserver that was at /js/global.js and made a static resource with a url of /js/global.js ... was that stupid? What should I do?
          Put it somewhere else; if you wanted it secured from access, you could even put it outside the webroot somewhere. Just don’t put it at the same location as the virtual Static Resource URL. MODx friendly URL rewrite rules are ignored if a physical file or folder exists by that name on the webserver.
            • 21872
            • 95 Posts
            Ah, so I was being stupid. Thanks for clarifying.