Answer the question
In order to leave comments, you need to log in
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>
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question