MODX Template Variables (TV) Setup

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

MODX Template Variables (TV) Setup

Template Variables are additional resource fields in MODX. They allow adding arbitrary data to pages: images, prices, dates, dropdowns, galleries, text blocks. Each TV is bound to one or more templates.

TV Types and Usage

Type Usage
Text Short text field
Textarea Multi-line text
RichText WYSIWYG editor
Number Numeric field (price, quantity)
Date Date with calendar
Image Image selection from media browser
File File upload or selection
URL Link
Email Email with validation
Checkbox Single checkbox (yes/no)
Listbox (single) Dropdown
Listbox (multi) Multiple selection
Radio Options Radio buttons
Tag Tags separated by comma
autotag Auto-complete from existing tags
migxdb Complex structure (MIGX)

Creating TV via Manager

Elements → Template Variables → Create:

  • Name: product_price (Latin only, underscores)
  • Caption: Price (displayed in editor)
  • Input Type: Number
  • Default Value: 0
  • Templates: select templates where field should appear
  • Access Tab: field order in interface, field group

Input Types with Settings

Listbox (Single) — Dropdown:

Input Type: Listbox (Single)
Input Options:
Color==Color||Size==Size||Weight==Weight

Or from database:
@SELECT `id`, `name` FROM `site_content` WHERE `template`=5 AND `published`=1

Image with media browser restriction:

Input Type: Image
Input Options:
[[++base_url]]assets/images/products/

Checkbox group:

Input Options:
monday==Monday||tuesday==Tuesday||wednesday==Wednesday||thursday==Thursday||friday==Friday

Output Type: delim (values separated by ||)

Displaying TV in Template

[[- Basic output ]]
[[*product_price]]

[[- With formatting ]]
[[*product_price:number_format=`0,.`, ` `]] ₽

[[- Conditional output ]]
[[*product_image:notempty=`<img src="[[*product_image]]" alt="[[*pagetitle]]">`]]

[[- With phpthumb ]]
[[*product_image:phpthumb=`w=800,h=600,zc=1`]]

[[- File link ]]
[[*product_brochure:notempty=`<a href="[[*product_brochure]]" class="btn">Download Brochure</a>`]]

Getting TV via Snippet

// Get TV programmatically
$resource = $modx->getObject('modResource', $resourceId);
$price = $resource->getTVValue('product_price');
$image = $resource->getTVValue('product_image');

// Set TV programmatically
$resource->setTVValue('product_price', 1500);

TV Organization via FastTab

FastTab allows grouping TVs by tabs in resource editor:

Tab "SEO": seo_title, seo_description, seo_robots
Tab "Product": product_price, product_sku, product_weight
Tab "Gallery": gallery (MIGX)
Tab "Content": hero_image, hero_text, features_json

Checking TV Completion

// In snippet — check completion before output
$tvValue = $resource->getTVValue('important_field');
if (empty($tvValue)) {
    $modx->log(modX::LOG_LEVEL_WARN, "TV important_field empty for resource {$resource->id}");
}

Timeline

Creating and configuring 10–20 TVs for project with template binding and FastTab grouping — 3–5 hours.