Post by Qphoria » Thu Oct 23, 2008 4:29 am

So the other override idea was to put a new override subfolder into each folder, and then put the contribbed version of the file being replaced into that folder. If an override existed, use it, otherwise, fallback to the core. This worked good, but it can be a lot of extra folders which can get confusing.

The New, NEW, idea is to have a separate main folder for "contribs" which would run along side of the main folders, and follow the same directory structure as the rest of the files.

For Example:

Core file:
/catalog/controller/product.php

Contrib override file:
/contrib/catalog/controller/product.php

The same easy code change would still apply to the library files:
- library/application/controller.php
CHANGE:

Code: Select all

$file = $this->directory . basename($action['class']) . '.php';
TO:

Code: Select all

$file = DIR_BASE . 'contrib/controller/'. basename($action['class']) . '.php';
if (!file_exists($file)) {
    $file = $this->directory . basename($action['class']) . '.php';
}
The same global on/off option could be used as well from the admin section.
But in comparison to my other override idea, this one is:
- a lot less excess (and usually empty) folders.
- a lot less confusing (since there won't be an intermingling of core and custom throughout the main folders)
- a lot easier to debug and follow which contribs you've installed and which is causing the problem.
- a lot easier to see if 2 contribs conflict (since it will warn you about file overwrite)
- a lot easier to use existing contribs without them having to be restructured and reuploaded. Just tell people to extract them into the "contrib" folder
- a lot easier for me to release it as a contrib for people to try (other idea would be hard to make as a contrib)

So I think I just beat out my genius idea with an even geniuser idea :P 8)
Last edited by Qphoria on Thu Oct 23, 2008 7:26 pm, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Thu Oct 23, 2008 7:29 pm

Visual example:

How does it work?
It is very simple to use the override. There are no files to modify or any special versions needed. The only thing you need to change is the location that you upload the files to.

Normally, you would install a contribution to match the directory structure of your cart. For example:
If your file directory is like this, you would normally upload the files to match the directory structure:

http://www.unbannable.com/old.jpg[/img]


Now, instead of using the normal directory structure, just upload the full structure to the “contrib” folder. Like this:

http://www.unbannable.com/new_contrib_override.jpg[/img]


That’s it! The contribs will still behave normally and OpenCart will have no problem interfacing with the files.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by bruce » Thu Oct 23, 2008 8:28 pm

Just can't let it go, can you.  :D

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by Qphoria » Thu Oct 23, 2008 8:50 pm

NEVER!  ;D
My genius just evolves!

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by bthirsk » Thu Oct 23, 2008 9:50 pm

You build it, they will come.

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by JNeuhoff » Fri Oct 24, 2008 3:01 am

How about something like this, to better take into account multiple contributions:

Attachments

???
contrib.png

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Fri Oct 24, 2008 3:27 am

First. I like that blue folder tree:)

Second. It is a good idea to keep them all separate, but where are those folder titles defined at? Adds another level of definition.

Third. The simple way also allows for multiple contribs.

Fourth. The simple way and even your way still have the problem of 2 contribs changing the same file (exluding the admin menu, just talking controller files, etc).

There is still just no good way to run 2 files of the same kind without merging their contents on the fly, unless each line is it's own include file.

product.php would remove all functional code, then create a product subfolder and have only a recursive file loop:
       

Code: Select all

if ($dir=@opendir('controller/product')) {
            while (($element=readdir($dir))!== false) {
                if ($element!= "." && $element!= "..") {
                    $array[] = $element;
                }
            }
            closedir($dir);
        }
        
        foreach ($array as $arr) {
            include($arr);
        }
And in the controller/product folder would be:
- name.inc
- price.inc
- options.inc
- addtocart.inc
etc.

Then each contrib could modify the individual pieces that they changed, without hogging the whole file.
Last edited by Qphoria on Tue Jan 13, 2009 12:29 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 1 guest