Post by Qphoria » Sun May 26, 2013 6:12 am

I've made my case a few times to theme makers that prefer to split off parts of pages and call them with their own

Code: Select all

include('xxx.php');
calls

But that breaks it when using vQmod because it assumes the relative path. And since vQmod changed files run out of the vqcache path, the solution is to use the full absolute path to where it "should" be, but to be sure it is dynamic per site.
I always used the following:

Code: Select all

include(DIR_SYSTEM . '../path/to/file/xxx.php');
as that will use the DIR_SYSTEM path which is guaranteed to exist and be constant among all opencart stores.
I include the '../' to tell the code to go up one level which is the parent directory of the "system" folder
That is the guaranteed way to find the root folder of the cart. From there you can build the path to your file. Alternatively you can use:

Code: Select all

include(dirname(DIR_SYSTEM) . '/path/to/file/xxx.php');
which functionally does the same thing.

But aside from making it work with vQmod, it also has its other benefits from a code perspective shown here:
http://www.kavoir.com/2010/02/php-why-y ... e-php.html

Read down to the "a better approach" part....

So not only does it make it vQmod compatible, it also speeds things up a tad

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 2 guests