PyroCMS 2.0 Documentation

← Table of Contents


Understanding the addons directory

The /addons directory is the main location for all custom code and is simply a CodeIgniter "Application Package". The main purpose of this folder is to store all third-party or custom modules, widgets and plugins but it can also be used to share custom config, libraries, helpers and language files between your addons.

Below is a full list of folders you can put in the addons directory:

  • config/
  • helpers/
  • language/
  • libraries/
  • models/
  • modules/
  • plugins/
  • themes/
  • widgets/

All of your custom code should fit into one of those folders and should be developed in the same way as you normally would in a CodeIgniter application.

An important note here is that you cannot extend helpers or libraries found in the system/ direction (neither system/pyrocms/ or system/codeigniter) as the CodeIgniter Loader class does not know to look there. This is a "limitation" of CodeIgniter itself, so if you need to exten core files you will need to either extend in system/pyrocms or extend there. If you do this make sure you are tracking your changes with Git as otherwise you will end up loosing your modifcations next time you upgrade PyroCMS.

In a similar way there are limitations on what config files you can put into here. For example config files like autoload.php, database.php and routes.php will have no effect here. It is reccomended you only put custom config files in here that will be loaded and used within your own add-ons.

As of version 1.3.0 the organization of add-ons has changed slightly to make way for multi-site support. While the above docs are still applicable keep the following in mind: add-ons are now stored both in addons/default/ and in addons/shared_addons/. This is because the Professional version allows super-admins (the users in control of the entire installation) to make some add-ons available to every site within the installation.

You can use the addons/shared_addons folder in exactly the same way as the old addons/ folder. The only difference is that when you upload a module or a theme from the site's admin panel it will be placed in addons/default/. Then if you upgrade to the Professional version at some point that theme, module, or widget will be confined to one site only. If you upgrade to Professional the add-ons for each additional site that you create will be placed in their own folder: addons/site_name