Blog Sections Open

Updating TV Values for a Specific Resource Through the Evolution API

A straightforward pattern for changing one resource TV programmatically instead of trying to fake the edit form by hand.

If you need to update a TV for one known document id, the cleanest path is to use the Evolution API directly instead of trying to simulate the manager form submission.

That keeps the operation explicit and makes the code easier to maintain, especially when the update runs from a snippet, module, or background script.

The practical pattern

$docId = 123;
$tvId = 46;
$value = 'new value';

$modx->db->update(
    array('value' => $value),
    $modx->getFullTableName('site_tmplvar_contentvalues'),
    "tmplvarid='{$tvId}' AND contentid='{$docId}'"
);

If the TV value does not yet exist for that document, insert it instead of updating. The important part is that the target is clear: one TV, one resource, one controlled operation.

Why this is better than form emulation

  • fewer side effects,
  • no need to mirror manager POST payloads,
  • easier debugging when one value does not save correctly.

For repeatable automation, direct API or database-level TV updates are usually more predictable than trying to imitate the full edit form lifecycle.

Newer post

Sending SMS Notifications After eForm Submission

A practical pattern for triggering SMS notifications from an Evolution CMS form after the normal eForm submission flow succeeds.

Older post

Escaping Double Curly Braces in Evolution CMS Templates and Chunks

How to keep third-party JavaScript templates that use {{ and }} intact without letting Evolution CMS treat them as its own syntax.