Page 1 of 1

Trying to make mobile detect plugin

Posted: Thu Jul 12, 2018 7:30 pm
by danguss
I found this old thread on mobile detect. I want to implement it.
viewtopic.php?f=7&t=66545

I created my UDT "mobile_detect".
then added {mobile_detect} to my template and trying to get conditional with {$deviceType} to work.
but no response, not sure where to put my mobile_detect.php class

Code: Select all

function smarty_function_mobile_detect($params, $smarty)
{
include_once('/mobile_detect.php');
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$smarty->assign('deviceType', $deviceType);
}
cmsms 2.2.7
server has 7.1 php

Re: Trying to make mobile detect plugin

Posted: Thu Jul 12, 2018 8:33 pm
by Rolf
The CGExtensions module already has a mobile detect plug-in included. Check the help text.

Grtz Rolf

Re: Trying to make mobile detect plugin

Posted: Thu Jul 12, 2018 9:43 pm
by danguss
Rolf wrote:The CGExtensions module already has a mobile detect plug-in included. Check the help text.

Grtz Rolf
But it doesn't work for all mobile devices for example it doesn't recognize a lot of samsung models

Re: Trying to make mobile detect plugin

Posted: Thu Jul 12, 2018 10:16 pm
by Rolf