Under Development: Override system
Posted: Wed Jul 30, 2008 11:20 pm
One of the better features of zen-cart was the use of an override folder to avoid making any changes to the core files, and making adding and removing contribs very easy since you'd just remove the override file, rather than having to edit the core file to add the new code.
From the contribs I've looked at tho, there doesn't seem to be any type of override system in place. Instead, the contribs use modified core files that just get overwritten. Which means to back out any contribs, you would need to reupload the official ones. This also means that if you have multiple contribs for the same page, you are stuck manually merging them into your core file which can get messy for those that don't know php very well.
I haven't seen any kind of override system planned, so I will attempt it and see if it is something that others agree with. The overall design shouldn't be too hard. Zen-cart did it by putting the overrides into a subfolder within the root location that matched the name of the template folder:
includes/templates/default/header.php
was overridden by
includes/templates/mytemplate123/header.php
includes/languages/english.php
was overridden by
includes/languages/mytemplate123/english.php
This worked pretty good. You still run into the problem when you have 2 contribs modifying the same file, like 2 contribs that modify the header.php file. One adds some advanced search options, the other adds a random logo generator. But that may or may not be avoidable.
If there was some way that it could all be modular at an even lower level than the template name, it would be near perfect for adding multiple contribs to one section. Some kind of class extends system to each file that would load the default, but override the default with the new code where the same variable name is used.
But for now, the first step could be a template folder name override, and that is what I will be working on here.
Thoughts?
From the contribs I've looked at tho, there doesn't seem to be any type of override system in place. Instead, the contribs use modified core files that just get overwritten. Which means to back out any contribs, you would need to reupload the official ones. This also means that if you have multiple contribs for the same page, you are stuck manually merging them into your core file which can get messy for those that don't know php very well.
I haven't seen any kind of override system planned, so I will attempt it and see if it is something that others agree with. The overall design shouldn't be too hard. Zen-cart did it by putting the overrides into a subfolder within the root location that matched the name of the template folder:
includes/templates/default/header.php
was overridden by
includes/templates/mytemplate123/header.php
includes/languages/english.php
was overridden by
includes/languages/mytemplate123/english.php
This worked pretty good. You still run into the problem when you have 2 contribs modifying the same file, like 2 contribs that modify the header.php file. One adds some advanced search options, the other adds a random logo generator. But that may or may not be avoidable.
If there was some way that it could all be modular at an even lower level than the template name, it would be near perfect for adding multiple contribs to one section. Some kind of class extends system to each file that would load the default, but override the default with the new code where the same variable name is used.
But for now, the first step could be a template folder name override, and that is what I will be working on here.
Thoughts?