Zen Cart Logo
Forums / Contribution-Writing Guidelines / Best way to use custom class between catalogue and admin

Best way to use custom class between catalogue and admin

Views: 5,600

Results 1 to 2 of 2
27 Oct 2013, 10:42 AM
#1
venablc avatar

venablc

New Zenner

Join Date:
Apr 2012
Location:
Norwich, Norfolk
Posts:
5
Plugin Contributions:
0

Best way to use custom class between catalogue and admin

Hi,

What is the expected way to use a class both within the catalog and also admin? is it to use the init system? or do I just need to do a normal "require", store the class in the catalog classes directory and fiddle about with the require path?

27 Oct 2013, 2:42 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,081
Plugin Contributions:
56

Re: Best way to use custom class between catalogue and admin

You'd place your new class file in /includes/classes/new_class.php. To load the class file, on the store-front side, you'd use:

require(DIR_WS_CLASSES . 'new_class.php');

On the admin side, you'd use

require(DIR_WS_CATALOG . 'includes/classes/new_class.php');

That's "assuming" that the class is not required to be loaded for each and every page in store-front and admin. If that's the case for you, post back and I'll provide an update.