MobileDetect class in Common Template html header
Good day,
This seems to be a very minor issue, and moreover, everything is probably Ok in fact and it's me, who does not understand something, but I'd like to wonder anyway, if this code is correct?
Code:
// ZCAdditions.com, ZCA Responsive Template Default (BOF-addition 1 of 2)
if (!class_exists('MobileDetect')) {
include_once(DIR_WS_CLASSES . 'Mobile_Detect.php');
}
$detect = new Detection\MobileDetect;
$isMobile = $detect->isMobile();
$isTablet = $detect->isTablet();
if (!isset($layoutType)) $layoutType = ($isMobile ? ($isTablet ? 'tablet' : 'mobile') : 'default');
// ZCAdditions.com, ZCA Responsive Template Default (BOF-addition 1 of 2)
(lines ##32...40 of includes\templates\responsive_classic\common\html_header.php file in newest v2.1.0)
Re: MobileDetect class in Common Template html header
Re: MobileDetect class in Common Template html header
Thank you for prompt reply for incompetent question
No need to reply, but logic does not seem flawless: after checking of obsolete class existence, new instance is being created from new location nonetheless
(I do definitely not understand something...)
Thank you again for your time.
Re: MobileDetect class in Common Template html header
Not incompetent at all - these things are quite tricky which is why they are explicitly called out in the documentation.
Re: MobileDetect class in Common Template html header
Sorry, just realized you were asking a question:
> No need to reply, but logic does not seem flawless: after checking of obsolete class existence, new instance is being created from new location nonetheless
It's checking to see if the class has been loaded - not all templates will load this class. If it hasn't, load it. Then create an instance of the class.
The class is not obsolete; it has been renamed and this new logic uses the new name.