Rubicon or Delaware
Building Software Which Crosses Rivers
Tim Otten Email: totten@civicrm.org IRC: totten
Rubicon or Delaware Building Software Which Crosses Rivers Tim - - PowerPoint PPT Presentation
Rubicon or Delaware Building Software Which Crosses Rivers Tim Otten Email: totten@civicrm.org IRC: totten Good Morning Agenda Background & example Notable APIs and Services Extension development - demo Core
Building Software Which Crosses Rivers
Tim Otten Email: totten@civicrm.org IRC: totten
Munroe, Randall. Online Communities 2. (http://xkcd.com/802/)
joomla.org
wordpress.com
drupal.org
joomla.org
wordpress.com
drupal.org
"JFactory::getDocument()
"add_action( 'wp_head', 'my_callback'');" "drupal_add_html_head"
CiviCRM'ish: $system->addHTMLHead("<script type='text/javascript' src='/civicrm/goodstuff.js'></script>");
CiviCRM'ish: $system->addHTMLHead("<script type='text/javascript' src='/civicrm/goodstuff.js'></script>"); CiviCRM'ish (How it works): class CRM_Utils_System { abstract function addHTMLHead($head); } class CRM_Utils_System_Joomla extends ... { function addHTMLHead($head) { $document = JFactory::getDocument(); $document->addCustomTag($string); } }
class CRM_Utils_System_WordPress ... { protected $htmlHeadBuffer = ''; function addHTMLHead($head) { $this->registered = FALSE; if (!$this->registered) { add_action('wp_head', array($this, '_showHTMLHead')); // front-end views add_action('admin_head', array($this, '_showHTMLHead')); // back-end views } $this->htmlHeadBuffer .= $head; } function _showHTMLHead() { return $this->htmlHeadBuffer; } }
Ridpath, John Clark Cyclopedia of Universal History(Cincinnati, OH: The Jones Brothers Publishing CO., 1885). Via etc.usf.edu.
Drupal Joomla WordPress
What Civi Does
drupal_add_html_head( "<script src=..." ) JFactory::getDocument()
"<script src=..." ) add_action( 'wp_head', 'my_callback'); function my_callback() { return "<script src=..."; }
What CMS Says You Should Do
drupal_add_js(...) JFactory::getDocument()
add_action( 'wp_enqueue_scripts', 'my_callback''); function my_callback() { wp_register_script(...); wp_enqueue_script(...); }
Benefits of Doing It the CMS Way
Aggregate JS/CSS files Compress CSS files Cache Compiled JS/CSS files Internationalization Weights Aggregate JS (inline) (Plugin) Minimize JS (Plugin) Minimize JS files (Plugin) Aggregate JS/CSS files [No caching] Dependencies Unregistration
Source: Coleman Watts, Donald Lobo
Leutze, Emanuel. Washington Crossing the Delaware (1851). Via wikipedia.org
$system->addHTMLHead( "<script type='text/javascript'>...</script>"); CRM_Core_Resources::singleton()
;
(Frontend, Backend; Civi- based or CMS-based)
Bridges
Bootstrap
Permissions
Shared Code
Templates
Add Javascript
CRM_Core_Resources::singleton()->addScriptFile(' com.example.foo ', 'bar.js'); CRM_Core_Resources::singleton()->addScript('alert("Hello")'); {crmScript ext= com.example.foo file=bar.js}
Add stylesheets
CRM_Core_Resources::singleton()->addStyleFile(' com.example.foo ', 'bar.css'); CRM_Core_Resources::singleton()->addStyle(' body { background: black; } '); {crmStyle ext= com.example.foo file=bar.css}
Add images, sounds, etc
CRM_Core_Resources::singleton()->getUrl(' com.example.foo ', 'bar.png'); {crmResURL ext= com.example.foo file=bar.png}
CRM_Core_Region::instance('page-header')->add(array( 'markup' => '<p class="example">Hello!</p>', )); CRM_Core_Region::instance('page-header')->add(array( 'markup' => '<p class="example">Hello!</p>', 'weight' => -5, )); CRM_Core_Region::instance('page-header')->add(array( 'template' => 'CRM/Myextension/mytemplatefile.tpl', )); CRM_Core_Region::instance('page-header')->update('default', array( 'disabled' => TRUE, ));
/** * Declare a report which should be activated whenever this module is enabled */ function modulename_civicrm_managed(&$entities) { $entities[] = array( 'module' => 'com.example.modulename', 'name' => 'myreport', 'entity' => 'ReportTemplate', 'params' => array( 'version' => 3, 'label' => 'Example Report', 'description' => 'Longish description of the example report', 'class_name' => 'CRM_Modulename_Report_Form_Sybunt', 'report_url' => 'mymodule/mysbunt', 'component' => 'CiviContribute', ), ); }
Version Themes 1.x API v1/v2 Custom Template Dir / Custom PHP Dir Drupal Modules
Version Themes 1.x API v1/v2 Custom Template Dir, Custom PHP Dir Drupal Modules 2.x Custom Searches, Custom Reports 3.x CiviCRM Payment, Report, and Search Extensions API v3 Joomla Plugins
Version Themes 1.x API v1/v2 Custom Template Dir / Custom PHP Dir Drupal Modules 2.x Custom Searches / Custom Reports 3.x CiviCRM Payment, Report, and Search Extensions API v3 Joomla Plugins 4.x CiviCRM Module Extension Civix Extension Directory
Platform Package Type CiviCRM APIs CMS APIs Civix Distribution CiviCRM (Any CMS) Extension (Module) APIv3, Hooks, BaseClasses, Templates None Yes civicrm.org (browse) Drupal Module APIv3, Hooks, BaseClasses*, Templates* CRUD, Hooks, etc No drupal.org (upload / url) Joomla Extension (Plugin) APIv3, Hooks, BaseClasses*, Templates* CRUD, Events, etc No joomla.org (upload / url) WordPress Plugin APIv3 [More IP?] CRUD, Actions, Filters, etc No wordpress.org (browse)
○ Administer => System Settings => Directories ○ Administer => System Settings => Resource URLs
○ civix generate:module -h ○ civix generate:page -h
See Also: Tutorial on creating & publishing extensions http://wiki.civicrm.org/confluence/display/CRMDOC43/Create+an+Extension http://bit.ly/10gOmNv
address submitting every database change
○ Create SQL table ○ Insert into SQL table during hook_civicrm_post
○ Create page ○ Add page as tab
○ Install CiviCRM from tarball ○ Gitify ○ Fork
○ Make branch ○ Code ○ Submit pull request
Tutorial on using Github & CiviCRM http://wiki.civicrm.org/confluence/display/CRMDOC43/GitHub+for+CiviCRM http://bit.ly/12M8yfr
Tutorial on creating & publishing extensions http://wiki.civicrm.org/confluence/display/CRMDOC43/Create+an+Extension http://bit.ly/10gOmNv Reference on APIs, hooks, etc http://wiki.civicrm.org/confluence/display/CRMDOC43/Developer+Reference (Alt) http://bit.ly/13yXiBZ CiviCRM developer tools https://github.com/totten/civix https://github.com/eileenmcnaughton/civicrm_developer Tutorial on using Github & CiviCRM http://wiki.civicrm.org/confluence/display/CRMDOC43/GitHub+for+CiviCRM http://bit.ly/12M8yfr
Tim Otten Email: totten@civicrm.org IRC: totten