Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Using Extra Resources in XC5

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 03-02-2015, 11:38 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Default 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?
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote
  #2  
Old 03-10-2015, 12:50 PM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default 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.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #3  
Old 03-11-2015, 05:42 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Default 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?
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote
  #4  
Old 03-11-2015, 09:53 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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?
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #5  
Old 03-11-2015, 10:04 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Default 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.
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote
  #6  
Old 03-17-2015, 11:45 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default 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.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #7  
Old 03-17-2015, 09:28 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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,
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #8  
Old 03-18-2015, 05:35 AM
  zychen's Avatar 
zychen zychen is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 48
 

Smile 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!
__________________
X-Cart 5.1.10
X-Cart Next 5.2.1 Beta
Reply With Quote

The following user thanks zychen for this useful post:
qualiteam (03-19-2015)
  #9  
Old 03-18-2015, 12:23 PM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Using Extra Resources in XC5

Yes, that is OK approach.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote

The following user thanks tony_sologubov for this useful post:
zychen (03-19-2015)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:21 AM.

   

 
X-Cart forums © 2001-2020