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

Module Development - Stuck

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 09-02-2015, 05:25 AM
 
cleverwise cleverwise is offline
 

Advanced Member
  
Join Date: Jun 2014
Posts: 74
 

Default Module Development - Stuck

Hello Community,

I am trying to figure out the layout of X-Cart 5 (5.2.6 to be exact) as I need to add a few features. I have programmed my own PHP solutions so I am not a newbie but I am having a little trouble understanding the layout of this application.

I have read the page and watch the video at:

http://kb.x-cart.com/display/XDD/Webinar+1+-+18+Mar+2014+-+developing+modules+for+X-Cart+5

What I was wondering is if anyone knows any other good places to start learning module development? One of the disadvantages of above is the name of the module and calls are both News.

However let's say you want to add a ticket system to X-Cart. Your target maybe called tickets where as the directory is MyDev\\TicketSystem. In this case it isn't just News and News for everything but TicketSystem in some places and Tickets in others.

I am starting to get the layout but it hasn't quite totally clicked for me yet. So if anyone has any ideas I would appreciate it!

Thank you!
__________________
Respectfully,

Jeremy

X-Cart 5.3 running on:
* Web server: Nginx with PHP-FPM via FastCGI (Opcache enabled)
* Database: Percona Server
* OS: CentOS
Reply With Quote
  #2  
Old 09-02-2015, 05:48 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Module Development - Stuck

classes/XLite/Modules/MyDev/TicketSystem will be the base directory for your module and the base namespace.

But "targets" are tied to controller classes (and their names), not to the base directory.
Please check this article: http://kb.x-cart.com/display/XDD/Controller+class
__________________
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

The following user thanks qualiteam for this useful post:
cleverwise (09-02-2015)
  #3  
Old 09-02-2015, 09:03 AM
 
cleverwise cleverwise is offline
 

Advanced Member
  
Join Date: Jun 2014
Posts: 74
 

Default Re: Module Development - Stuck

Do you know the best way to just have code?

I have some advanced functions where I need to make multiple queries and parse the information before submitting data to the screen and would just prefer a function or whatever I can just code in PHP vs having to link five, six, ten files. I say this because I was watching that creating module video and one needs to go Model, then Model/Repo, then Admin/en/View, etc. I just want to make my call and then write hundreds of lines of PHP code.

I do understand the desire to have XC allow for less PHP coding by using templates but I honestly prefer systems that just link to a blank slate like say Wordpress where one can just start freely programming.

I know this isn't WP but I have created dozens of modules for that system (along with applications) and you just linked into a few functions and off you go writing all the code you want without having to deal with dozens of separate small template files to link things together. In WP the module has to be self contained. I again know XC isn't WP but all I want is just call a main function and freely program.
__________________
Respectfully,

Jeremy

X-Cart 5.3 running on:
* Web server: Nginx with PHP-FPM via FastCGI (Opcache enabled)
* Database: Percona Server
* OS: CentOS
Reply With Quote
  #4  
Old 09-02-2015, 08:07 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Module Development - Stuck

Hello Jeremy,

Quote:
I do understand the desire to have XC allow for less PHP coding by using templates

Using templates is not our goal. Our goal is the ability to upgrade X-Cart 5 and modules to new versions without breaking the site (or, at least, making the process of fixing the site after an upgrade as easy as possible).

That's why you must implement all your changes to the X-Cart 5 site via modules, and not via scripts that "just have code".
__________________
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

The following user thanks qualiteam for this useful post:
cleverwise (09-03-2015)
  #5  
Old 09-03-2015, 03:17 AM
 
cleverwise cleverwise is offline
 

Advanced Member
  
Join Date: Jun 2014
Posts: 74
 

Default Re: Module Development - Stuck

Thanks for the reply.

I do understand about making upgrading easy. I think you missed what I was saying though. I didn't mean putting code just anywhere.

I will refer back to Wordpress for a just a moment, not that that application is perfect or the only one I have developed modules on (WHMCS and Clickcartpro are other systems just to name a few more).

The way WP does it is every module must be self contained in its own directory/folder than is installed in the wp-content/plugins. However unlike X-Cart one doesn't have to create several small template files. What a developer does is inside say wp-content/plugins/my_unique_plugin is they create say index.php and then just call a few functions that hook into WP's calls.

Then a developer defines their own unique function calls and can program dozens, hundreds, or thousands of lines of standard php code. All this can be done from within the single index.php inside wp-content/plugins/my_unique_plugin (as an example). Still many developers will start breaking their long code into other files and hooking them in.

On an upgrade if the module my_unique_plugin breaks something one can just upgrade the code in that directory or simply disable the module. So it helps in upgrading, maintaining plugins, and creating plugins since one doesn't need to generate many small template file calls.

That was what I was trying to say. I realize X-Cart doesn't work that way but IMO it makes it a lot harder than say Wordpress, WHMCS, ClickcartPro, etc. I agree developers should keep all their code in a module directory and just hook into the main system without just adding php script code in any main file.

Thanks again for the reply and I hope that clarifies what I was trying to say.
__________________
Respectfully,

Jeremy

X-Cart 5.3 running on:
* Web server: Nginx with PHP-FPM via FastCGI (Opcache enabled)
* Database: Percona Server
* OS: CentOS
Reply With Quote
  #6  
Old 09-03-2015, 07:53 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Module Development - Stuck

Well, Wordpress is made of functions and X-Cart is made of classes. Keeping every class in its own file is the best practice for working with classes in PHP - this way any class can be autoloaded when needed without using the "require" statement to load the class declaration.

As for small templates - it allows you to replace small bits of the HTML code from your modules without affecting other portions of the page (custom skins that substitute the base one: http://kb.x-cart.com/display/XDD/Basic+guide+to+theme+creation).

Also, it makes possible for your modules to inject new widgets and templates into the existing HTML code without even touching core files/templates (look for "view list" at http://kb.x-cart.com/display/XDD/Working+with+viewer+classes).
__________________
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

The following user thanks qualiteam for this useful post:
cleverwise (09-04-2015)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


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 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 08:55 AM.

   

 
X-Cart forums © 2001-2020