X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Using Extra Resources in XC5 (https://forum.x-cart.com/showthread.php?t=71517)

zychen 03-02-2015 11:38 AM

Using Extra Resources in XC5
 
Hi Everyone,

I'm working on an API integration that requires me to reference a wsdl file in my module.

However, XC5 does not seem to cache unrecognized files from my module so I end up with "File not found" errors.

I assume this is the same with any other file resource.
How do I add such file resources and reference them from my PHP code?

tony_sologubov 03-10-2015 12:50 PM

Re: Using Extra Resources in XC5
 
Hi @zychen!

Could you please give me a little more details about when you are getting "File not found" error? X-Cart does not cache unrecognized, so I do feel this is a problem with something else.

Tony.

zychen 03-11-2015 05:42 AM

Re: Using Extra Resources in XC5
 
Hi Tony,

It shouldn't be an X-Cart problem.
It's just that I'm not sure what the proper way is to get the path of my extra file for my module.

Since the files are executed in the cached run folder instead, a relative path isn't going to work but I don't want to hardcode my absolute directory paths to get the extra file.

Basically, where would you suggest I place such files and how should I access them in code?

qualiteam 03-11-2015 09:53 AM

Re: Using Extra Resources in XC5
 
Hello Yong,

Please could you explain what you want to achieve?

Do you want to bundle your X-Cart 5 module with some non-PHP files which will be loaded from your PHP scripts later?
Should these files be "bundled", or will/can you create them from your scripts on the fly?

zychen 03-11-2015 10:04 AM

Re: Using Extra Resources in XC5
 
Hi Alex,

Thanks for replying.

Quote:

Originally Posted by qualiteam
Do you want to bundle your X-Cart 5 module with some non-PHP files which will be loaded from your PHP scripts later?


Yes, that is what I want - to bundle an existing non-PHP file to my module.

tony_sologubov 03-17-2015 11:45 AM

Re: Using Extra Resources in XC5
 
Quote:

Originally Posted by zychen
Hi Alex,

Thanks for replying.

Yes, that is what I want - to bundle an existing non-PHP file to my module.


Do you mean files like images? If so, you can put them into skins/ folder and then use them from there.

qualiteam 03-17-2015 09:28 PM

Re: Using Extra Resources in XC5
 
Hi Yong,

It depends on how your scripts retrieve these files:
1. If the script are a part of your module, I believe you can use something like __DIR__ . '/../../../../../../../classes/XLite/Module/[YOUR_ID]/[MODULE_ID]'
2. If the script is an external service loading the files via an HTTP request, you can put these files into the "[XC5]/skins/en/customer/modules/[YOUR_ID]/[MODULE_ID]" directory as Tony suggested.


How will you reference the files? If there is another script that should retrieve the files via an HTTP request,

zychen 03-18-2015 05:35 AM

Re: Using Extra Resources in XC5
 
My file is a .wsdl (or .xml) file accessed by my local module code.

I might have found the best way to do this if there isn't a dedicated folder for such files.
I have found some handy directory constants leftover from LiteCommerce in /top.inc.PHP53.php so I have used one of those.

Here's what I used:
PHP Code:

$path LC_DIR_MODULES "[YOUR_ID]/[MODULE_ID]/[Relative Path to Extra File]" 


Do you think this is a good way?

Thanks Tony and Alex!

tony_sologubov 03-18-2015 12:23 PM

Re: Using Extra Resources in XC5
 
Yes, that is OK approach.


All times are GMT -8. The time now is 06:52 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.