The main element of external component is Info.php file. It contains PHP class which defines all the information about the component and implements a couple of methods needed by the system. Required elements in CRM_ComponentName_Info class are: CRM_ComponentName_InfoClass properties:protected $keyword <= defines the unique keyword for the component, used in different places Class methods:function getInfo() <= provides information about the component to the system.Needs to return an array defining values for the following keys:
function getPermissions() <= needs to return the array of permissions used by this componentfunction getUserDashboardElement() <= registers a user dashboard (/civicrm/user) element, can return empty array if user dashboard not used.Needs to return an array defining values for the following keys:
function registerTab() <= registers contact view (/civicrm/contact/view) tab, can return empty array if contact tab not usedNeeds to return an array defining values for the following keys:
function registerAdvancedSearchPane() <= registers advanced search pane (/civicrm/contact/search/advanced) for this component, can return empty array if advanced search not usedNeeds to return an array defining values for the following keys:
function getActivityTypes() <= does nothing at the moment, but needs to be implementedEntry in civicrm_component tableOnce you have you Info.php file, you need to add the entry to civicrm_component table. This tables has only three columns:
Example: if you're writing a component called YourComponent and put all the component files in $civicrm_root/CRM/YourComponentPath directory, you need to do the following: Create a table entry: Create an Info class in file $civicrm_root/CRM/YourComponentPath.php, the class name should be CRM_YourComponentPath_Info XML paths definitionsAfter you have db entry and Info class, you need to create an xml file which will define all the URL paths that you're going to use in your component. This file needs to be placed in $civicrm_root/CRM/YourComponentPath/xml/Menu/AnyName.xml Properties of each <item> mean:
Do a menu rebuildIf you modify/add to the XML menu file, you need to rebuild the CiviCRM menu tables. You can do this from the web browser via: q=civicrm/menu/rebuild&reset=1 (for drupal/standalone) Next StepsThe following notes were collected from Michal Mach during a Birds of a Feather DupalCon SF session April 19, 2010. They outline some of the initial setup required before actual coding of the functionality of the module begins. /CRM/Touchstone - present in svn repository but nto tarballs: is a template developed circa 2008 for new component but is now a bit outdated in terms of how things are / should be done setup /CRM/ComponentName/Config.php to hold configuration settings, eg color = 'GREEN'; see CRM/Mailing/Config.php for a good example /CRM/ComponentName/PseudoConstant.php - if needed for performance /CRM/Core/Component/* defines the minimum abstract classes that need to be implemented for any component /CRM/Core/Component.php - has base stuff for other components /CRM/ComponentName/xml/Menu/ComponentName.xml - has the menu /xml/schema/ComponentName/TableName.xml - define each table needed by component here /CRM/ComponentName/DAO/TableName.php - autogenerated by /xml/GenCode.php from /xml/schema/ComponentName/TableName.xml using templates /CRM/ComponentName/BAO/TableName.php contains all business layer logic for data storage, validation, retrieval sometimes there is a /CRM/ComponentName/BAO/ComponentName/Utils.php for helper classes |
Creating custom components
Labels
