Forums / Bug Reports / MobileDetect class in Common Template html header

MobileDetect class in Common Template html header

Views: 851

Results 1 to 5 of 5
12 Mar 2025, 5:33 PM
#1
yesaul avatar

yesaul

New Zenner

Join Date:
Apr 2011
Location:
Espoo, Finland
Posts:
73
Plugin Contributions:
0

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?

// 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)

12 Mar 2025, 6:16 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: MobileDetect class in Common Template html header

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

12 Mar 2025, 7:07 PM
#3
yesaul avatar

yesaul

New Zenner

Join Date:
Apr 2011
Location:
Espoo, Finland
Posts:
73
Plugin Contributions:
0

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.

12 Mar 2025, 7:11 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

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.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

13 Mar 2025, 11:14 AM
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

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.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.