Hiya,
I'm having trouble require'ing a class file from an admin file. I have zen cart 1.3.8a in a normal apache install, located at web root, nothing fancy. I've written a custom class (or three) e.g. /includes/classes/warranty.base.php which work fine from the customer-facing /includes/... side of things.
My admin side has a helper class in /admin/includes/classes/warranty.php. How should I require my warranty.base.php file from the admin's warranty.php file? That is, a class file in /admin/includes/classes is trying to include a class file from /includes/classes. I'd like to use the zen cart defines such as DIR_WS_WHATEVER if possible.
generates:PHP Code:require(DIR_WS_CLASSES . 'warranty.base.php');
That makes sense, the path should not be relative to admin, it should be relative to web root. A very basic hardcoded attempt that I thought should work..Code:PHP Warning: require(includes/classes/warranty.base.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in <obscured>/admin/includes/classes/warranty.php on line 8
generates:PHP Code:require('/includes/classes/warranty.base.php');
I'm confused as to why that second attempt failed.Code:PHP Warning: require(/includes/classes/warranty.base.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in <obscured>/admin/includes/classes/warranty.php on line 8
The warranty.base.php file definitely exists, I can direct my browser to my.site.com/includes/classes/warranty.base.php and get 200 OK.
Annoyingly, this does work:
This would seem to resolve to "includes/classes/../../../includes/classes/warranty.base.php", which relative to the /admin/includes/classes/warranty.php file would be "/admin/includes/classes/../../../includes/classes"PHP Code:require(DIR_WS_CLASSES . "../../../includes/classes/warranty.base.php");
Thanks!
Nick





