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


Different content for desktop and mobile on one page in about 5 minutes.
md_disable_plugin = No| You have pdoTools + Fenom | HTML template without Fenom |
|---|---|
| Fenom blocks (step 3a) | HTML tags (step 3b) |
In a template or chunk parsed by pdoTools via Fenom:
{mobile}
<p>Content for phone and tablet</p>
{/mobile}
{desktop}
<p>Desktop content</p>
{/desktop}[[!pdoPage?
&element=`tplContent`
]]The {mobile} block shows for mobile or tablet. For phone without tablet use {phone} (Integration).
In the resource body or template:
<standard>
<p>Desktop content</p>
</standard>
<mobile>
<p>Phone content</p>
</mobile>The plugin on OnWebPagePrerender removes extra blocks before sending the page. Tag names are configured via md_standard_node, md_mobile_node, md_tablet_node.
Внимание
MODX tags and snippets inside HTML blocks parse before filtering. For conditional heavy snippets prefer Fenom — see Integration.
standard / {desktop} blockmobile / {mobile} block?browser=mobile to the URL (parameter name is md_force_browser_variable, default browser)The package includes chunk tplMobileDetectSwitch — Desktop / Tablet / Mobile / Auto links:
{$modx->getChunk('tplMobileDetectSwitch')}[[$tplMobileDetectSwitch]]?browser=mobile and ?browser=detect work[[+mobiledetect.device]] is set (standard, tablet, or mobile)