In Fakoli, a set of files that perform a related purpose within your application would be organized into a Component. For example, the code for the Fakoli CMS feature that manages templates is stored in the component "template", the code for the Menu feature is stored in the component "menu." In fact, even components themselves need code to manage them, thus there is the component which is appropriately named "component."
Your application can extend or override Fakoli's components. In your application directory structure, you can add your own components in a folder called "component". You can name your components anything you wish except for names already used in Fakoli, unless you wish to override the component completely.
For example, your website might have a component called "order" for managing customer orders. Within that component, you would create one or more of the following folders:
Directly under the order folder, you could have files that include supporting classes such as order_view.inc and validate_order.inc.
Components that contain a data model must also contain a schema SQL file (e.g., order_schema.sql) with its table and view create statements and a code file containing the upgrade manager class to handle schema updates (e.g., order_upgrade_manager.inc)
Each component you write must contain a file called manifest.inc directly under the component's folder. This is the file that registers your component with Fakoli CMS, gives it a unique name within the CMS, and specifies whether it is enabled or not. The manifest also lets you specify where you want any admin files to appear within the CMS menu.
The following code is an example of a manifest for the order component:
class OrderManifest { static function getComponentDefinition() { $component = new Component(); $component->name = "order"; $component->description = "Details of orders."; $component->author = "Jane Smith"; $component->version = "1.0"; $component->priority = 0; $component->enabled = true; return $component; } static function getAdminMenu() { return array ( "Classification" => array ( "Products" => array("page" => "/admin/product_list" "role" => "admin" "weight" => 10) ) ); } static function getStyles() { return array("/components/order/css/order.css"); } static function getScripts() { return array("/components/order/js/order_manager.js"); } static function subscribeToEvents() { return array("upgradeComponent" => array(OrderManager, upgradeComponent), "ComponentScanComplete" => array(OrderManager, setDefaults), "upgradeComponent" => array(OrderManager, upgradeComponent) ); } }
The manifest links the CMS admin page "product_list.inc" into the Classification menu with a weight of 10. The weight works like a sort order but allows you to be approximate, rather than exact in your assignments. A weight of 10 would place the menu item near the bottom if most other items are weighted less.
After you create a new component, you need to run a component scan to get Fakoli CMS to search for new components to be incorporated into the CMS. The Components menu item displays a list of all registered CMS components. At the bottom is a button "Scan for Component Updates." When clicked, Fakoli will find your new component through the manifest. When the scan is complete, your new admin menu item will appear under "Classification" and your order component will be included in the list of components.
Your component pages will also now appear in Sections under Component Pages items, available to be added to your site. Please note that before you can view any component page through the browser, you must add those specific pages to at least one section.