Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Trying to autoload new class

Trying to autoload new class

Views: 904

Results 1 to 2 of 2
20 Jun 2013, 2:12 AM
#1
dan123 avatar

dan123

New Zenner

Join Date:
Apr 2008
Posts:
82
Plugin Contributions:
0

Trying to autoload new class

Hello!

I am trying to add a new class to my shop but so far no luck. To be more specific I am trying to setup my zen to autoload mobile-detect class on all pages (https://github.com/serbanghita/Mobile-Detect). What I have done so far:

  1. added Mobile_Detect.php file to /includes/classes/observers
  2. created new file - config.mobile_detect.php in /includes/auto_loaders with:
<?php  
  $autoLoadConfig[200][] = array('autoType'=>'class',
                              'loadFile'=>'observers/Mobile_Detect.php');
  $autoLoadConfig[200][] = array('autoType'=>'classInstantiate',
                              'className'=>'Mobile_Detect',
                              'objectName'=>'Mobile_Detect');
// eof

But whenever I am calling it a get an error - "PHP Fatal error: Call to a member function isMobile() on a non-object in" what can be missing or I am just too naive for it to work with zen?

Thank you for your help,
Dan!

20 Jun 2013, 2:31 AM
#2
dan123 avatar

dan123

New Zenner

Join Date:
Apr 2008
Posts:
82
Plugin Contributions:
0

Re: Trying to autoload new class

I am sorry it turned out I called objectname -"Mobile_Detect" and I should have called it just "detect". Please correct me if I am wrong)