Warning: Overriding /core/ files makes it very unlikely that automatic CMS upgrades will go well. If you're overriding important /core/ files and folders, it's recommended that you turn off automatic CMS upgrade prompts in your configuration file.

How It Works

Almost any file in the /core/ folder can be overridden by a file at an equivalent path in /custom/. For instance, if you wanted to create a custom version of the BigTreeModule class you could copy /core/inc/bigtree/modules.php and place it in /custom/inc/bigtree/modules.php.

When including files in the CMS, BigTree almost always uses the BigTree::path method to find out whether a custom override exists. This enables you to drop in replacement functionality overriding a single file and not have to worry about modifying other files that may include it.

Extending Without Overriding

Two BigTree classes can be extended without overriding files in /core/. Those classes are BigTreeCMS and BigTreeAdmin. They are normally represented by the $cms and $admin variables, respectively. If your configuration file is setup properly, you can override the default classes that $cms and $admin are set to so that you can extend their functionality.

In BigTree 4.1+, you will be editing /custom/settings.php — in BigTree 4.0, you will be editing /templates/config.php. If the following lines don't exist, you can add them:


BIGTREE_CUSTOM_BASE_CLASS refers to the class name that contains your extension of BigTreeCMS.
BIGTREE_CUSTOM_ADMIN_CLASS refers to the class name that contains your extension of BigTreeAdmin.
BIGTREE_CUSTOM_BASE_CLASS_PATH is the path of the file that contains your BigTreeCMS extension class relative to the /site/ folder (i.e. if your file is in /custom/my-class.php your path should be "../custom/my-class.php"). Likewise, BIGTREE_CUSTOM_ADMIN_CLASS_PATH is the path of the file containing your BigTreeAdmin extension class.

BigTree 4.2+ introduce BigTreeCMSBase and BigTreeAdminBase as the classes which you should be extending (rather than BigTreeCMS and BigTreeAdmin). This is due to many methods in the two classes being statically called in 4.2+. BigTree gets around this by actually extending your extension class. For example:

    class MyClass extends BigTreeCMSBase {};

BigTree then extends it via "class BigTreeCMS extends MyClass". Now whenever BigTreeCMS::staticMethod(); is called, your custom class has the ability to override it rather than simply instances of $cms and $admin.