I like the MVC structure, code looks clean! I was wondering, is it a custom made framework or a spin-off of some other MVC styled framework?
In any case, I'm having trouble finding a good way to extend OpenCart. From what I see so far with modules and contributions is that they just overwrite core files.
What happens when I upgrade then? My store will be broken.
I was thinking, why not implement some kind of event based system like Wordpress has? Or, can I extend and override catalog/controller/common/header.php's index() function? How would the loader know I've done so?
I'm wondering because I'd like to develop some modules and make OpenCart one of the tools in my arsenal, and it's awesome that it uses MVC. But how am I supposed to keep track of each little modification I make to all the controller files, then I have to manually check my change log for each of my clients installations? On one client I just changed the header, on the other I rewired so much, I don't think I'd risk upgrading... ever... hahaha
Anyone know what I mean? I'm hoping that there's a programatically sound way to extend OpenCart... but from what I've seen the conrtibs are more like hacks... one that I just installed said 'over write x file and y file, and if you've installed a DIFFERENT module before, MERGE the changes!'
hahahaha, it's the same crap you have to deal with in all the other old school carts.
Don't get me wrong though, besides the non-existing plugin architecture OpenCart is awesome.
I propose we all help the creator and come up with a plugin architecture that makes sense, and doesn't break when you upgrade...
I've seen something, the addPreAction and dispatch functions... but there's little developer documentation.
I really like the coding style of OpenCart though... are there any other developers contributing?
If it's a totally new module or add-on (eg. a forum) then it would allow itself to become a library or extension, because it could sit alongside the existing classes, but in some cases it doesn't seem possible.
I would love to have a look at the wordpress style plugin architecture and see how they insert plugin specific functions into posts & pages (& what other types of insertion points can be supported & how). Usually there is always tweaking involved, but in terms of opencart, it would be great if this tweaking could be isolated to the views, rather than having to update the existing controllers and models.
Let's keep this discussion alive, I think it would be beneficial to see real code examples or discuss why things may or may not work for opencart.
http://www.alreadymade.com
Follow me on twitter.com/alreadymade
What I'm doing is adding a commented lines beginning where I change things and and end comment to signify that's where the normal file starts again. Upgrading will be tedious... but at least I'll know what I edited.
This has been discussed a few times.
Q has some good ideas as seen in this thread http://forum.opencart.com/viewtopic.php ... enu#p41536
I would love for Daniel to get in on this discussion and see if we can come up with something to be rolled into one of the next few versions of opencart. I think it would really help things moving forward.
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
You should have looked in "catalog/controller/common/home.php" (line 29):3rdcorner wrote:... had to edit the products model (catalog/model/catalog/product.php) so I could show the 4 latest products from our 5 most popular categories, and including all their children so that was a good couple of hours.
Code: Select all
foreach ($this->model_catalog_product->getLatestProducts(8) as $result) {
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!
Negative. The Extension system uses completely standalone files and loads them dynamically.3rdcorner wrote:From what I see so far with modules and contributions is that they just overwrite core files.
At this time "Extensions" include
Sideboxes, payment, shipping, order totals, and feeds.
Yes, I've been doing lots of searching for a good override system (see this thread) and you are correct that one is needed. I've also toyed with an SMF style approach where it modifies the file based on a patching/installer system that I've got workingI was thinking, why not implement some kind of event based system like Wordpress has? Or, can I extend and override catalog/controller/common/header.php's index() function? How would the loader know I've done so?
Modules are transparent, but yes, core mods are definitely dangerous and each change should be documented and commented. You can try to also keep your changes local to the template file and use a custom template name so that updates don't overwrite. My override ideas from the other thread I linked above would solve some of this at the file level, but not at the individual function level.I'm wondering because I'd like to develop some modules and make OpenCart one of the tools in my arsenal, and it's awesome that it uses MVC. But how am I supposed to keep track of each little modification I make to all the controller files, then I have to manually check my change log for each of my clients installations? On one client I just changed the header, on the other I rewired so much, I don't think I'd risk upgrading... ever... hahaha
I think my explaination above should have cleared this up.Anyone know what I mean? I'm hoping that there's a programatically sound way to extend OpenCart... but from what I've seen the conrtibs are more like hacks... one that I just installed said 'over write x file and y file, and if you've installed a DIFFERENT module before, MERGE the changes!'
There are a few of us.I really like the coding style of OpenCart though... are there any other developers contributing?
Yea I did, that's where I found that those products are loaded from the product model.fido-x wrote: You should have looked in "catalog/controller/common/home.php" (line 29):Code: Select all
foreach ($this->model_catalog_product->getLatestProducts(8) as $result) {
Thanks for all the replies, I'm reading those threads now.
When the plugin is activated, it is "plugged" to the hook that placed on the main core function and on the front end template files.
Wordpress, instead of writing the new hacks into the core files.
It "hook" the new programming line into an empty function in the core files which act as a container for new programming line.
So its like we write the new hacks into the core file itself.
When the plugin is deactivated, the programming line then removed from the empty functions that serve as the container and we have been reverted to default.
We don't have to touch the core file at all.
I really hope that open cart can implement this type of architecture.
To have a hacks that appear where it should be, then we should put an optimum hooks at selected location as a container for new programming line and when we need to put something there such as sidebars, admin back end new tab, we just "hook" the new functions to that functions container.
I don't have a formal php lesson.
But I've been working with wordpress plugin for abour 2 years now and I am very happy that it is easy to extend wordpress for someone who learn php from University of Google...
My Open Cart online shop: Guan8871 Free Shipping Online Shop
My personal blog: Wiguan88.com
Blog where I post my online activities such as web development: PANGERAN.ORG
there is no override functionality at this point and time. Yes it's been discussed several times, but nothing has been done.Mucus wrote:Has there been any progress on the overrides idea? I've seen threads stretching back a couple of years, but so far no luck finding anything about it in the documentation. The reason I ask is I want to move a bunch of stuff from the header templates to the footer templates because I find the default templates a little top-heavy and I want the page content closer to the top of the HTML, but this means I also have to modify the controllers, and I guess the only clean way to do that will be through this discussed override functionality.
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
That would be great, it would allow a whole other level of customizability.Qphoria wrote:Perhaps now it is time to begin looking at that again.
That said, I'm extremely impressed with OpenCart, I've just completed my first fully customized template, it's just the inability to move code between files that's preventing me from going that extra step.
Well I'm not sure how that would change from the override step. Override would just prevent core files from being overwritten.Mucus wrote: That said, I'm extremely impressed with OpenCart, I've just completed my first fully customized template, it's just the inability to move code between files that's preventing me from going that extra step.
Moving code around is different. I am looking into some hook options but its all up in the air still.
Correct me if I'm wrong, but the header controller contains the data needed by the language module. If I move the language module from the header template to the footer template, I get the error "Notice: Undefined variable: languages in..." meaning I have to move a few lines from the header controller to the footer controller, but I'd rather not modify those files, but instead override them so they won't be overwritten when I upgrade OpenCart.Qphoria wrote:Well I'm not sure how that would change from the override step. Override would just prevent core files from being overwritten.
Code: Select all
$this->data['language_code'] = $this->session->data['language'];
$this->load->model('localisation/language');
$this->data['languages'] = array();
$results = $this->model_localisation_language->getLanguages();
foreach ($results as $result) {
if ($result['status']) {
$this->data['languages'][] = array(
'name' => $result['name'],
'code' => $result['code'],
'image' => $result['image']
);
}
}
<?php echo $languagebox; ?>
This used to be like this in 1.3.2 and earlier when there was a common layout. It was extremely simple
Then someone got this idea to make the controller the parent file so that each controller could choose which children were loaded.. but since nobody cares about that, and the children list is still hardcoded anyway.. it was a huge step backwards. Perhaps in 1.5.x the template system can be changed (yet again) to be something more like joomla where the layout is completely independent of controller and you can have a simple layout that you just add the "tags" to... something like:
Code: Select all
<html>
<body>
<div id="header">
<?php echo $headerData; ?>
<?php echo $search; ?>
<?php echo $language; ?>
</div>
<div id="columnLeft">
<?php echo $leftColumnData; ?>
</div>
<div id="columnRight">
<?php echo $rightColumnData; ?>
</div>
<div id="content>
<?php echo $contentData; ?>
</div>
<div id="footer>
<?php echo $footerData; ?>
</div>
</body>
</html>
You can blame the community members that are also template creators for agreeing to the new design that started in 1.3.3. They all said they liked it... but Qphoria knew better
I'm another newcomer to OC loving the crisp use of MVC, and working on a module that requires a function to occur with every successful call to model_checkout_order->confirm. So far, my module has kept core completely untouched, using $_GET and session data to make module functions roughly coincide with the appropriate core functions. That's not going to work for a model function.
I'd love to leave my clients with the simplest possible housekeeping instructions for when they wish to update OC. So, I'm just wondering: is there a better or more future-proof method to extend a vital Core function like this than tacking something like "if x module enabled, do y function from module" into function confirm(...) in model/checkout/order.php? Some method that is most in line with current thinking about how the future hook system might work?
If there's a clear direction emerging for how this will work, I could also be up for contributing what I can to help make it happen from my modest experience of hooks in Drupal.
Users browsing this forum: No registered users and 126 guests