Static template does not process MODX tags (they show as text)

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:

<html>
    <head>
        <title>[[*pagetitle]]</title>
    </head>
    <body>
        <h1>[[*longtitle]]</h1>
        [[*content]]
    </body>
</html>

The output on the web page in the source code is literally this, with the unprocessed MODX tags:

<html>
    <head>
        <title>[[*pagetitle]]</title>
    </head>
    <body>
        <h1>[[*longtitle]]</h1>
        [[*content]]
    </body>
</html>1

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).

Welcome to the community! :slight_smile:

Do you get any errors in the logs regarding your problem?

How is the the chunk content getting on the page (e.g., a chunk tag, snippet, getResources, etc.)?

How did you load your static file?

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:

  1. Navigate to [Content > Content Types] (The top menu within MODx)
  2. Find the row for [HTML]
  3. 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:

<html lang="en">
<head>
<title>[[*pagetitle]]</title>
</head>
<body>
<h1>[[*longtitle]]</h1>
<div id="content">
[[*content]]
</div>
</body>
</html>

The resulting web page shows up in a browser like this:

[[*longtitle]]
[[*content]]
1

(The number “1” is showing up there, presumably because PHP is saying something is “true,” which means that something is wrong in this case.)

Here’s what the template looks like in MODX:

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.