This is my first time using CMSMS and after researching, I found I had to use the User Defined Tags (UDTs) to use custom php. I did that successfully and all my code worked. I wanted to include a php file for mobile detection, but when I do and refresh the page, it's just a completely blank page.
When I view the source, it's entirely empty. I have an if
statement after the include and narrowed it down to the include line being the problem. It's very simple:
include '/Mobile-Detect.php';
$detect = new Mobile_Detect;
// any mobile device (phones or tablets)
if($detect->isMobile()){
if(!$_COOKIE['ppc'] == 'true'){
header('Location: /mobile');
}else{
header('Location: /mobile?ppc=true');
}
}
So I'm not sure why other blocks of code I have in other UDTs works and the include doesn't even throw an error. Hopefully a more experienced CMSMSer can help me out on this.
Thank you
I got around it by editing the include.php
file at the root level. I first had to check if it was an admin page or not since the file is included in the front and back end. Then ran my code to check for mobile devices.
End result:
if(!isset($CMS_ADMIN_PAGE)){
// code to be executed on non-admin pages
}
Note: I also tried javascript, but in the UDT it was expecting php, so I added it to the template and then it was trying to render the curly braces in my if statement as smarty tags. So annoying.