
MobileDetect
Device type detection in MODX and different content on a single page


Compares the current device type with parameter &input and returns 1 (match) or 0 (no match).
Important: call uncached — [[!MobileDetect]]. With cache the result is the same for all visitors.
| Parameter | Description | Default |
|---|---|---|
&input | Expected type: standard, tablet, mobile | mobile |
Types match getDeviceType() from the MobileDetect service.
[[!MobileDetect:is=`1`:then=`
<p>Mobile content</p>
`:else=``:input=`mobile`]]{if $modx->runSnippet('MobileDetect', ['input' => 'mobile']) == 1}
<p>Mobile content</p>
{/if}[[!MobileDetect:is=`1`:then=`
<p>Tablet content</p>
`:else=``:input=`tablet`]]{if $modx->runSnippet('MobileDetect', ['input' => 'tablet']) == 1}
<p>Tablet content</p>
{/if}[[!MobileDetect:is=`1`:then=`
<p>Desktop content</p>
`:else=``:input=`standard`]]{if $modx->runSnippet('MobileDetect', ['input' => 'standard']) == 1}
<p>Desktop content</p>
{/if}[[!MobileDetect:is=`1`:then=`
[[$mobileHeader]]
`:else=`
[[$desktopHeader]]
`:input=`mobile`]]{if $modx->runSnippet('MobileDetect', ['input' => 'mobile']) == 1}
{$modx->getChunk('mobileHeader')}
{else}
{$modx->getChunk('desktopHeader')}
{/if}MobileDetect servicemd_force_browser_variable)resolveDevice() — cookie, GET, or User-Agent$input with current type (case-insensitive)(int) matchPlaceholder [[+mobiledetect.device]] is set by the plugin, not the snippet.