Blog Sections Open

Working with `documentObject` and TV Output Through the Evolution CMS API

How to read document fields and TV values correctly through the Evolution CMS API.

When people first start using the Evolution API, one of the most confusing points is the difference between document fields and template variables. They may all feel like “page data”, but they do not live in the same structure.

A typical starting point looks like this:

$id = $modx->documentIdentifier;
$doc = $modx->getDocument($id);
$tvs = $modx->getTemplateVarOutput('*', $id);

The important distinction is:

  • documentObject or getDocument() gives you core fields such as id, pagetitle, alias, and other standard resource properties;
  • getTemplateVarOutput() gives you TV data, which is separate and may need its own output handling.

This matters when building snippets, API endpoints, export scripts, or custom renderers. If you expect a TV inside the document field array, you will eventually end up debugging “missing” values that were never supposed to be there in the first place.

As a mental model, think of the resource and its TVs as two coordinated data layers. Once you do that, working with the Evolution API becomes much more predictable.

Newer post

Using Language-Specific TV Names in Multilingual Evolution CMS Projects

A practical approach to multilingual TV values using suffixed field names such as tvname_ru and tvname_en.

Older post

Handling Multiple File Uploads in eForm for Evolution CMS

What to change when a single-file eForm workflow needs to accept several uploaded files in one submission.