Blog Sections Open

Rendering Checkbox TV Values with DocInfo and DocLister

Checkbox TVs often store IDs or raw value strings. This pattern turns them into readable output in a listing.

Checkbox TVs are useful, but their stored values are not always presentation-friendly. A practical way to use a TV with IDs from child resources and then render those values in a human-readable form inside a DocLister listing.

Generate the TV options dynamically

@EVAL return $modx->runSnippet('DropDownList');
<?php
$childs = $modx->getActiveChildren(10); // 10 = parent resource ID
$out = array();
foreach ($childs as $child) {
    $out[] = $child['pagetitle'] . '==' . $child['id'];
}
echo implode('||', $out);
?>

Use the TV in DocLister

[[DocLister?
  &documents=`[+id+]`
  &tpl=`doclisterList`
  &tvList=`list`
]]

Render readable values with DocInfo

[[DocInfo? &docid=`[+id+]` &tv=`1` &field=`list` &render=`1`]]

When render=1, the output becomes readable labels. When render=0, you still get the raw stored value such as 11||12||13.

Why this pattern matters

Many Evo projects keep relational data in TVs because it is fast to build and easy for editors to understand. The problem comes later, when the frontend needs labels, links, or nested markup instead of raw IDs. Combining a dynamic TV source with DocInfo gives you a much safer output layer than trying to parse the stored value inside every chunk.

Newer post

Using UltimateParent to Resolve Top-Level Sections in Evolution CMS

A quick guide to using UltimateParent in Evolution CMS when you need the top-level ancestor of the current resource or another document.

Older post

Creating Checkbox-Based Catalog Filters with tagManager

How to build checkbox-style product filters with tagManager in Evolution CMS and keep the filter URLs and templates predictable.