Post by Qphoria » Tue Jul 22, 2008 9:55 pm

To those that have a good understanding of OpenCart.. maybe you can help answer these questions.

Question 1: From what I can gather, it appears that most of the core stuff is in the "Controller" folder and the modifications are stored in the "Extensions" folder. And the Extensions override the Controller area. Is this correct?

Question 2: Assuming Q1 is true, It appears that the Extension modules seem to extend the "Controller" class instead of the direct module class that they appear to replace. I.E. Extension/modules/cart.php extends "Controller" instead of extending "ControllerCart" (the original cart class). Is this the normal way? Could you extend the base class directly without going straight to the controller to save on excess repetition of setting the same variables?

Question 3: Assuming Q2 is how it is done, How does the code use the file name as part of its equation? I see the controller/search.php is "ControllerSearch" and the extension/modules/search.php is "ModuleSearch". But does the actual file name play any role? Could I just use "blah.php" as long as I specify the words "ModuleSearch" in the class?

Thanks!
Last edited by Qphoria on Tue Jul 22, 2008 9:59 pm, edited 1 time in total.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Tue Jul 22, 2008 10:47 pm

Ok, from my testing I see that you add the Extension to the admin area. Oddly, while the extensions are in the database for the default stuff like "Admin Header, footer, etc" there are actually NO extensions showing up in my install of OpenCart. I added my own and I could see it. But it seems that it only shows up when there is NO "type" set in the database. When I added my own, OC apparently didn't fill the type in. As soon as I added it manually, it disappeared from all views.

So that appears to be some new bug in the latest OpenCart. Not sure which version is on OpenSourceCMS.com but it says Copyright 2006, so its likely quite old.

I'll post this in the bug area if its not already there. Fortunately, it appears that the actual function of the extension appears to be working, just the listing of them in the admin is broken so things still work.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Tue Jul 22, 2008 11:07 pm

What's the deal with "magic quotes"? Are they supposed to be used or should we be converting to standard ? In my experience magic ones just get confusing and break some things

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Tue Jul 22, 2008 11:51 pm

Ok. hm2k explained the extension list problem.
For those who don't know, it is because the "&" are being converted to "&" but the url needs to use the normal "&" not the converted style.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Wed Jul 23, 2008 1:41 am

Ah, yea i changed it to

Code: Select all

return htmlspecialchars_decode($server . $link);
but that way works too

Thx

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Wed Jul 23, 2008 3:15 am

Ok. So I've been testing with the extensions and stuff, trying to figure this stuff out but it's not working the way I thought.

I thought that the extension would overwrite the controller code, but that doesn't seem to be the case.

I got the page looking for my extension module, and I got my extension module to load its own language file. But variables don't pass from the controller to the extension, or vice versa, and therefore there are no variables being overridden as I assumed was the case.

I even tried extending the ControllerProduct class instead of the general Controller class, but that did nothing.

So can someone tell me how exactly extensions work?
Do they just append stuff to their core file? Or can they be used to manipulate data from that core file before display?
Last edited by Qphoria on Wed Jul 23, 2008 3:22 am, edited 1 time in total.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Wed Jul 23, 2008 3:32 am

After looking at some other contribs, it seems that they just replace core code... this is definitely a monkey wrench in the plans. Is there perhaps a way to use extensions to modify the core or simply override the core files so that they are never touched? As more contribs touching the same files occur, things are going to get real messy real fast. Originally I thought the extension was supposed to work like this, but it doesn't appear to.

Is this planned anytime soon? I suppose it could be possible with some code intervention using a wrapper to first check one path or the other for an override. Tho, a "mutator" system that can extend the individual classes and override at a per-variable/per-function level might be best.
Last edited by Qphoria on Wed Jul 23, 2008 3:34 am, edited 1 time in total.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by fido-x » Thu Jul 24, 2008 10:27 pm

Hi Qphoria,

The files in the "catalog/controller" directory are the controllers for the main pages. The controllers for the "extensions" are in the "catalog/extension/module" directory. While many of these files have the same name, they are for different purposes. Those in the "catalog/controller" directory are controllers for the "main" pages, while those in the "catalog/extension/module" are controllers for the module that appears in the column.

The controllers extract data from the database and from the language files. The structure of the language directory follows that of the catalog directory, so that the language files are associated with a specified controller. This data is then presented to the viewer or template files. These are found in the "catalog/template/default" directory. The templates in the "content" subdirectory are the templates for the "main" pages, while those in the "module" subdirectory are for the modules in the column.

Hope this helps you understand things a bit better.

Regards, Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Qphoria » Wed Jul 30, 2008 11:08 pm

Well that helps a little bit.

So just as a scenario, if I wanted to add a new extension to the product page, I would have to:
1. Create an /admin/controller/module_catalog_product.php file with "something" in it. (since it doesn't exist yet)
2. Create an /catalog/extension/module/myprodext.php file with "my" new module code in it.
3. Add the extension through the admin and use the new "module_catalog_product.php" file as the controller, "product" as the code, and myprodext.php as the filename.
4. In the myprodext.php file I would use "class ModuleProduct extends Controller"

And that would call the module_catalog_product.php file, which would call the myprodext.php file and place that code on the product page.

Am I in the ballpark?

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by fido-x » Thu Jul 31, 2008 7:02 pm

The "modules" and "extensions" that you are talking about are in the column and appear on every page (ie. Cart, Categories, Information & Review).

The files in the "admin/controller" directory that have a name like "module_catalog_filename.php" are the admin controllers for these modules. Once installed, the modules can then be enabled or disabled through the administration. If enabled, they will appear on every page. If disabled, they will not appear at all. The corresponding catalog controllers for these modules can be found in the "catalog/extension/module" directory.

The other files in the "admin/controller" directory (with names like "filename.php") allow you to add/edit entries in the database for the associated main page. For example, "admin/controller/information.php" is used to add information entries to the database, which are then extracted by "catalog/controller/information.php" and passed through the template file ("catalog/template/default/content/information.tpl") for viewing, while "admin/controller/module_catalog_information.php" is used to enable/disable the Information module in the column.

If you want to add something specific to the Products page that doesn't appear on any other page, the files you would need to edit are "catalog/controller/product.php", "catalog/language/english/controller/product.php" and "catalog/template/default/content/product.tpl".

Regards, Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Qphoria » Thu Jul 31, 2008 7:49 pm

fido-x wrote: If you want to add something specific to the Products page that doesn't appear on any other page, the files you would need to edit are "catalog/controller/product.php", "catalog/language/english/controller/product.php" and "catalog/template/default/content/product.tpl".

Regards, Fido-X.
But I want to make something that is controllable from the Admin area. For example, say I want to have a div box on my product page that contains some additional information that needs to be checked before the Add to Cart button is clickable. Or perhaps a Cross Sell contribution that can be defined in the admin area.

From the admin area, I want to be able to enable, disable, and configure this box. I understand that the code to call it would need to be added to the product.php/tpl files but I also would need to make a portal for the admin control named module_catalog_product.php right? As well as an extension for products.php in the admin area to support the configurable values?
Last edited by Qphoria on Thu Jul 31, 2008 7:52 pm, edited 1 time in total.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by fido-x » Thu Jul 31, 2008 9:15 pm

The administrative functionality that you want needs to be added to "admin/controller/product.php". Then in "catalog/controller/product.php" you can do some kind of check to see if this is required for a particular product. If it is required, the div would be displayed otherwise it wouldn't. However, I reckon you will probably need to add an extra field to the product table in the database to hold the value that you want.

Regards, Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Qphoria » Thu Jul 31, 2008 9:34 pm

I guess my mind set is trying to create something that adds on to the existing product page without modifying the core code. Like some sort of extensible plugin that I can drop my code into a subfolder and it will load on the product page or the admin product page. So I was thinking that if I made some sort of extension, I could easily add the extension via the admin area to the product page, without directly editing the product page, at least not too much.

I'm trying to figure out how we can make Opencart dynamically modular. The more contribs that are made, The more impossible it will be to upgrade to new versions of OC without destroying custom modifications. If we can keep the custom stuff in separate files, they won't be overwritten by new official OC versions.
Last edited by Qphoria on Fri Aug 01, 2008 2:59 am, edited 1 time in total.

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 5 guests