I’d like to move our templates over to static files, but when I did this, none of the MODX tags were processed. Any HTML shows up fine (headings, paragraphs, etc.), but if I refer to MODX page elements – such as [[*longtitle]] or [[*content]] – or MODX chunks or snippets – such as [[$myChunk]] and [[mySnippet]] – the MODX tags are displayed on the page as plain text and not processed. Any insights as to how to fix that?
I’m using MODX 2.7.1
This is an example of the literal text in the static file:
Also note the extra “1” at the very end of it all. That “1” shows up on the page and in the source code, but is not in the original file. I assume that’s a symptom of something not being processed as intended (PHP will sometimes output a “1” when a condition is true, for example).
Hopefully you’ve managed to resolve this already, but for anyone else running into the same situation, it’s quite likely that your HTML content type is being processed as binary. Here’s what to do:
Navigate to [Content > Content Types] (The top menu within MODx)
Find the row for [HTML]
Edit this row so that [Binary] is unchecked.
I find that simply unchecking the checkbox directly on the row item never actually saves the change, so best to right-click and choose ‘Edit’. In the dialog that pops up, set [binary] to be false, then close the dialog.
Clear your site cache, then reload one of the font-end pages to see the MODx tags being processed as expected.
Thanks for the responses. I guess I overlooked the earlier responses without realizing there were any. Sorry to bobray and ilja-web.
No, I haven’t fixed this yet. I looked at the content types and the HTML row was not marked as binary, so that’s not the problem. I noticed that the HTML row didn’t have a file extension, whereas the other rows did, so I added .html as the file extension [EDIT: I found out the hard way that this is a bad thing to do if you’re intending your URL to NOT end in .html], and for safe measure, I created a new row called HTM and designated it as text/html, with a file extension of .htm [EDIT: I had to undo this change too] That didn’t work for the method I’m attempting to use.
What I’m doing is creating a template as usual under Elements > Templates, and selecting “is Static.” I pull in the file (in this case it’s in the filesystem under tmp/staticTemplate.html. I save the template, and the file shows up just fine. Here’s the full content of that file:
I setup a test page using your info in 2.7.2 and it worked properly.
It looks like you are seeing the static file and not the database copy. You can test that by manually editing the file - for example change “[[*content]]” to “Testing”. If you see 'Testing" when you reload the web page you are getting the file not the database.
I would suspect there is a plugin running before the page loads that is picking the template from the file and not the database.