Hi,
So I'm trying to output a lengthy chunk of HTML code if the browser width is 590px or less (mobile view). I have a simple javascript function that determines the screen's width on resize, but how do I output a chunk if that function returns true?
The way I'm envisioning it is to have the function inside it's own chunk, but I can't get the chunk to return anything to any output filters, e.g. [[$isMobile:eq=`true`:then=`[[$MobileChunk]]`]]
Thanks
PHP Snippets are server side and JavaScript/CSS is client side. Any MODX snippet will already be parsed and giving you output before screen re-sizing etc happens.
That being said JavaScript can import, redirect or load additional code on browser events.
if (screen.width > 1400) {
$('#wrapper').load('/map/map4.php');
} else {
$('#wrapper').load('/map/map1.php');
}
Frameworks like Bootstrap have CSS classes like "hidden-xs" that can be used to change what's being displayed on different screen sizes.