I’m really hoping someone can provide some help with this little issue. I need to detect iPhone/iPod/iPad and serve up an alternate chunk. So far this is the code I’ve implemented via snippet:
<?php
if(strpos($_SERVER['HTTP_USER_AGENT'],'iPhone') || strpos($_SERVER['HTTP_USER_AGENT'],'iPod') || strpos($_SERVER['HTTP_USER_AGENT'],'iPad')) {
$videoPlayer = $modx->getChunk('iphone-video');
// return the results
return $videoPlayer;
} else {
$videoPlayer = $modx->getChunk('default-video');
// return the results
return $videoPlayer;
}
My problem is that regardless of the device the "else" content is getting served. So clearly the user agent isn’t being recognized. Total loss as to why.
I’m calling the snippet uncached. Should I be using $modx->getUserData() instead? If so, how should I implement this into the above snippet block? I’ve searched high and low and can’t seem to find any relevant info.
Thanks in advance!
?>