Modx Syntax

Basis

Date Code

Format Code
2025 {'!now' | date_format: '%Y' | ucwords}
June {'!now' | date_format: '%B' | ucwords}
June 2025 {'!now' | date_format: '%B %Y' | ucwords}
June 30 2025 {'!now' | date_format: '%B %d %Y' | ucwords}
30.06.2025 {'!now' | date_format: '%d.%m.%Y' | ucwords}
2025-06-30 {'!now' | date_format: '%Y-%m-%d' | ucwords}
30 June 2025 {'!now' | date_format: '%d %B %Y' | ucwords}
Monday, June 30, 2025 {'!now' | date_format: '%A, %B %d, %Y' | ucwords}
We can use the next one to show a future or a past date.
We can set it up by specifing how much time we want to go ahead in te future or back in the past. In the next example we are specifying 30 days ahead.
July 30 2025 {'+30 days' | date_format: '%B %d %Y' | ucwords}

Country Code

Format Code
City { '!geo' | snippet : ['get' => 'city', 'local' => 'en'] }
State { '!geo' | snippet : ['get' => 'state', 'local' => 'en'] }
Country { '!geo' | snippet : ['get' => 'country', 'local' => 'en'] }
We can use the next code if the language is english
City { '!geo' | snippet : ['get' => 'city'] }
State { '!geo' | snippet : ['get' => 'state'] }
Country { '!geo' | snippet : ['get' => 'country'] }

Currency Code

Format Code
$ { '!geo' | snippet : ['get' => 'currency_sign'] }

Links

Description Code
Offer link { '!innerLink' | snippet }
Offer link for reviews or adblocks { \'!innerLink\' | snippet }
Offer link for reviews or adblocks { '!getParams' | snippet }

Some Syntax for Templates and Prelanders

How to use Code
Routing Template Folders { '!templatesBasePath' | snippet : ['path' => '/2_box_left_right/css/style-right2.css'] }
Image Routing { 'imagesBasePath' | snippet}/ }
Conditional for variables
If variable's empty, it won't show
{if $_modx->resource.variable_name != '' }
{$_modx->resource.variable_name}
{/if}
Conditional variable inside a block {if $image?}{/if}

Variables

Description Code
Format for variables uses in general content { $_modx->resource.variable_name }
Format for variables uses inside another variables [[*variable_name]]

Parameters

Description Code Old Code
New syntax for tid {$.get.tid} <?=!empty($_GET['tid']) ? $_GET['tid'] : ''?>
New syntax for adtitle {$.get.adtitle} <?=!empty($_GET['adtitle']) ? $_GET['adtitle'] : ''?>
New syntax for ttclid {$.get.ttclid} <?=!empty($_GET['ttclid']) ? $_GET['ttclid'] : ''?>
New syntax for campaign_id {$.get.campaign_id} <?=!empty($_GET['campaign_id']) ? $_GET['campaign_id'] : ''?>
New syntax for adgroup_id {$.get.adgroup_id} <?=!empty($_GET['adgroup_id']) ? $_GET['adgroup_id'] : ''?>
New syntax for site {$.get.site} <?=!empty($_GET['site']) ? $_GET['site'] : 'site'; ?>
If Parameter have this character -
Ex.: my-name
Parameter code will be: {$.get['my-name']}

Scripts

Description Code
Redirect Script <script> setTimeout(function(){ window.location.href = 'LINK'; }, 20000); </script>