D
D
DotDash2019-03-12 20:26:28
MODX
DotDash, 2019-03-12 20:26:28

How to branch connection of chunks in modx?

Kind!
How to branch connection of chunks in modx evo (Evolution CMS)?
I'm trying to make the choice of connecting a chunk separately for the mobile and desktop versions

<div class="col-md-12 col-lg-7 d-none d-md-block">
  {{large-block}}
</div>
<div class="col-md-12 col-lg-7 d-block d-md-none">
  {{small-block}}
</div>

With such a connection, the conflict, apparently, both chunks are connected.
How to connect only one chunk?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexalexes, 2019-03-12
@DotDash

Using the if snippet , you can make a condition on which resource to load content from in a particular place in the template.
Only here, to detect a mobile client, you need to write another snippet, as a test condition, in order to analyze the user_agent property.
PS: Something like this www.about-cms.com/opredelit-mobilnoe-ustrojstvo-mo... although you should be critical of such implementations in terms of the relevance of the methodology and the degree of crutch.

function mobile_detect() { 
$user_agent = $_SERVER['HTTP_USER_AGENT']; 
$ipod = strpos($user_agent,"iPod");
$iphone = strpos($user_agent,"iPhone");
$android = strpos($user_agent,"Android");
$symb = strpos($user_agent,"Symbian");
$winphone = strpos($user_agent,"WindowsPhone");
$wp7 = strpos($user_agent,"WP7");
$wp8 = strpos($user_agent,"WP8");
$operam = strpos($user_agent,"Opera M");
$palm = strpos($user_agent,"webOS");
$berry = strpos($user_agent,"BlackBerry");
$mobile = strpos($user_agent,"Mobile");
$htc = strpos($user_agent,"HTC_");
$fennec = strpos($user_agent,"Fennec/");
$nokia = strpos($user_agent,"Nokia");
if ($ipod || $iphone || $android || $symb || $winphone || $wp7 || $wp8 || $operam || $palm || $berry || $mobile || $htc || $fennec || $nokia) 
{
echo "<link rel='stylesheet' media='all' href='mobile.css' type='text/css' />";
} 
else
{
echo "<link rel='stylesheet' media='all' href='desktop.css' type='text/css' />";
}
}
mobile_detect();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question