SlideShare una empresa de Scribd logo
1 de 40
4/14/10 ©2010 SugarCRM Inc. All rights reserved. 1
Best Practices for Creating Custom Apps in Sugar	 John Mertic SugarCRM 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 2
The golden rules of customizations Use Module Builder/Studio for customizations if possible Otherwise, put your code inside the custom directory 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 3
Why do this? Module Builder/Studio changes are well supported and easier to manage Customizations are separated from the shipped code Allows you to manage your customizations via version control ( SVN, Git, etc ) Files in here aren’t disturbed by any Sugar upgrades Exception – sometimes we will try to fix metadata templates on upgrades for new/removed fields.	 Makes your app “Upgrade Safe” 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 4
Exceptions to this… New modules need to be under modules/ directory. Bean class customizations to OOTB modules need to be on the original bean file. We’ll look at using logic hooks and other techniques to avoid this for many use cases. Will need to manually manage this during upgrades, so best to avoid. 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 5
Let’s see what we can do 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 6
MVC Framework MVC stands for Model View Controller 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 7
MVC Framework – The anatomy of a request 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 8
MVC Framework – SugarApplication Bootstraps the application Loads many of the default application settings Language Theme Session Handles User Authentication Loads the controller 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 9
MVC Framework - SugarController Manages all the actions of a module Contains logic for handling requests that don’t require a view Example: Record saving Maps all other requests to the correct view Logic for mapping an action of one name to a view of another Can detect if we should be using MVC or classic views 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 10
MVC Framework – SugarController API 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 11
MVC Framework – Controller Example 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 12 <?php class ExampleController extends SugarController {     public function action_hello()     {         echo "Hello World!";     }     public function action_goodbye()     {         $this->view = 'goodbye';     } }
MVC Framework – Controller-less mapping If your module doesn’t need to have any controller logic, use action mapping insteads. Create file named action_view_map.php with the following contents: 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 13 <?php $action_view_map['goodbye'] = 'goodbye';
MVC Framework - SugarView Contains the display logic for the action Uses a metadata backend for Edit, Detail, List, Popup views And Convert Lead in Sugar 6.0 For other views, you write the code for the view and put it in modules/modulename/views/view.viewname.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 14
MVC Framework – SugarView API 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 15
MVC Framework – SugarView API 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 16
MVC Framework – View Example 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 17 <?php class ViewExample extends SugarView {     public function preDisplay()     {         if ( !is_admin($GLOBALS["current_user"]) ) sugar_die("Not an Admin");     }     public function display()     {         echo "Hello Admin!";     } }
MVC Framework – ViewDetail Example 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 18 <?php require_once('include/MVC/View/views/view.detail.php'); class ContactsViewDetail extends ViewDetail {  	public function display()   	{  	    $admin = new Administration();  	    $admin->retrieveSettings(); if(isset($admin->settings['portal_on'])   	            && $admin->settings['portal_on']) {  	        $this->ss->assign("PORTAL_ENABLED", true);            } parent::display();  	} }
4/14/10 ©2010 SugarCRM Inc. All rights reserved. 19 Where do I put my customizations? Controllers /custom/modules/Modulename/controller.php class CustomModulenameController extends SugarController Views /custom/modules/Modulename/views/view.viewname.php class CustomModulenameViewViewname extends ModulenameViewViewname If that class doesn’t exist extend from ViewViewname or SugarView
Metadata Layer 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 20
Kinds of metadata editviewdefs.php / detailviewdefs.php / quickcreatedefs.php Wireless variants: wireless.editviewdefs.php, wireless.detailviewdefs.php subpaneldefs.php listviewdefs.php wireless.listviewdefs.php searchdefs.php wireless.searchdefs.php SearchFields.php popupdefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 21
editviewdefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 22 <?php $viewdefs[$module_name]['EditView'] = array(     'templateMeta' => array(         'maxColumns' => '2',          'widths' => array( array('label' => '10', 'field' => '30'),  array('label' => '10', 'field' => '30'),             ),                                                                                                                                             ),     'panels' =>array (         'default' =>              array (                 array (                   'name',                   'assigned_user_name',                 ),  array(array(                   'name' => 'date_modified',                   'customCode' => '{$fields.date_modified.value} {$APP.LBL_BY} {$fields.modified_by_name.value}',                   'label' => 'LBL_DATE_MODIFIED', )),             ),             array(                 array (  'description',                 ),             ),         ),                   );
subpaneldefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 23 <?php $layout_defs[$module_name] = array(      'subpanel_setup' => array( 	'contacts' => array( 		'order' => 20, 		'module' => 'Contacts', 		'sort_by' => 'last_name, first_name', 		'sort_order' => 'asc', 		'subpanel_name' => 'default', 		'get_subpanel_data' => 'contacts', 		'title_key' => 'LBL_CONTACTS_SUBPANEL_TITLE', 		'top_buttons' => array( array('widget_class' => 'SubPanelTopButtonQuickCreate'), 			array( 				'widget_class'=>'SubPanelTopSelectButton', 				'mode'=>'MultiSelect’ 			), 		), 	),     ), );
searchdefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 24 <?php $searchdefs[$module_name] = array(     'templateMeta' => array(         'maxColumns' => '3',         'widths' => array('label' => '10', 'field' => '30'),         ),     'layout' => array(         'basic_search' => array(             'name', array('name'=>'current_user_only', 'label'=>'LBL_CURRENT_USER_FILTER', 'type'=>'bool'),             ),         'advanced_search' => array(             'name', array('name' => 'phone', 'label' =>'LBL_ANY_PHONE', 'type' => 'name'), array('name' => 'address_city', 'label' =>'LBL_CITY', 'type' => 'name'), array('name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name'), array('name' => 'assigned_user_id', 'type' => 'enum',  	      'label' => 'LBL_ASSIGNED_TO',                  'function' => array('name' => 'get_user_array',  	     		'params' => array(false))),         ),     ), );
SearchFields.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 25 <?php $searchFields[$module_name] = array (     'name' => array( 'query_type'=>'default'),     'current_user_only'=> array('query_type'=>'default', 	'db_field'=>array('assigned_user_id'),'my_items'=>true,  	'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),     'assigned_user_id'=> array('query_type'=>'default'), );
popupdefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 26 <?php global $mod_strings; $popupMeta = array(     'moduleMain' => 'Account',     'varName' => 'ACCOUNT',     'orderBy' => 'name',     'whereClauses' => array(         'name' => 'accounts.name',          'billing_address_city' => 'accounts.billing_address_city',         'phone_office' => 'accounts.phone_office'),     'searchInputs' => array('name', 'billing_address_city', 'phone_office'),     'create' => array(         'formBase' => 'AccountFormBase.php',         'formBaseClass' => 'AccountFormBase',         'getFormBodyParams' => array('','','AccountSave'),         'createButton' => $mod_strings['LNK_NEW_ACCOUNT’]),     'listviewdefs' => array(         'NAME' => array(             'width' => '40', 'label' => 'LBL_LIST_ACCOUNT_NAME', 'link' => true,'default' => true,),          ),     'searchdefs'   => array(         'name',  array('name' => 'assigned_user_id', 'label'=>'LBL_ASSIGNED_TO', 'type' => 'enum', 'function' => array('name' => 'get_user_array', 'params' => array(false))),         ),);
Where do I put my customizations? Subpaneldefs custom/Extension/modules/Modulename/Ext/Layoutdefs/NameWhateverYouWant.php Need to run ‘Quick Repair and Rebuild’ after changes are made Everything else /custom/modules/Modulename/metadata Watch for Studio blowing out your changes. 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 27
Logic Hooks 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 28
Logic Hook Types 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 29
Logic Hook Types (cont) 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 30
Logic Hook Types (new in 6.0) 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 31
logic_hooks.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 32 <?php $hook_version = 1;  $hook_array = Array();  $hook_array['before_save'] = Array();  $hook_array['before_save'][] = Array(1, 'AccountHooks',  'custom/Accounts/AccountHooks.php','AccountHooks', 'getParentAccountIndustry');  Parameters for Logic Hook Definition Parameter 1 - Sorting index used to sort the arrays of logic hook definitions before they are processed.Parameter 2 - A string value to identify the hookParameter 3 - Path to the PHP file to include which contains your logic hook codeParameter 4 - Name of the PHP class the logic hook method is inParameter 5 - Name of the PHP method to call
AccountHooks.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 33 <?php class AccountHooks {      public function getParentAccountIndustry(  SugarBean $bean,           $event,           $arguments          )      {          if ( empty($bean->industry)  		 && !empty($bean->parent_id) ) {              $parentAccountFocus = new Account();              $parentAccountFocus->retrieve($bean->parent_id);              if ( !empty($parentAccountFocus->id) )                  $bean->industry = $parentAccountFocus->industry;          }      }  }
Where do I put my customizations? Application Level Logic Hooks /custom/modules/ Module Level Logic Hooks /custom/modules/Modulename/ 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 34
Themes 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 35
Theme Directory Layout css/ - contains all css files images/ - contains all images js/ - contains any js files. tpls/ - smarty templates themedef.php definition file. 12/30/08 ©2009 SugarCRM Inc. All rights reserved. 36
Themes can inherit from other themes Theme Inheritance Model 12/30/08 ©2009 SugarCRM Inc. All rights reserved. 37
Allow upgrade-safe modifications to themes All themes can be modified by putting the replacement or overriding file in the custom/theme/<themename> directory Image, HTML template file overrides are used as a replacement of the previous file Example: an image custom/theme/<themename>/dog.gif would be used instead of theme/<themename>/dog.gif  CSS and Javascript files are combined in order of inheritance Uses cssmin and jsmin to help reduce file size No further code changes are required – changes are picked up automatically when themes cache is rebuilt. 12/30/08 ©2009 SugarCRM Inc. All rights reserved. 38
Resources 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 39 http://developers.sugarcrm.com Buy my book!
Thanks for coming! 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 40

Más contenido relacionado

La actualidad más candente

Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolGordon Forsythe
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentTammy Hart
 
How Can I tune it When I Can't Change the Code?
How Can I tune it When I Can't Change the Code?How Can I tune it When I Can't Change the Code?
How Can I tune it When I Can't Change the Code?Sage Computing Services
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for MagentoIvan Chepurnyi
 
AMD & Require.js
AMD & Require.jsAMD & Require.js
AMD & Require.jsEyal Vardi
 
Bringing Characters to Life for Immersive Storytelling - Dioselin Gonzalez
Bringing Characters to Life for Immersive Storytelling - Dioselin GonzalezBringing Characters to Life for Immersive Storytelling - Dioselin Gonzalez
Bringing Characters to Life for Immersive Storytelling - Dioselin GonzalezWithTheBest
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?brynary
 
Krazykoder struts2 plugins
Krazykoder struts2 pluginsKrazykoder struts2 plugins
Krazykoder struts2 pluginsKrazy Koder
 
Nashvile Symfony Routes Presentation
Nashvile Symfony Routes PresentationNashvile Symfony Routes Presentation
Nashvile Symfony Routes PresentationBrent Shaffer
 
Bringing characters to life for immersive storytelling
Bringing characters to life for immersive storytellingBringing characters to life for immersive storytelling
Bringing characters to life for immersive storytellingDioselin Gonzalez
 
Wordpress plugin development from Scratch
Wordpress plugin development from ScratchWordpress plugin development from Scratch
Wordpress plugin development from ScratchOcaka Alfred
 
Rebooting TEI Pointers
Rebooting TEI PointersRebooting TEI Pointers
Rebooting TEI PointersHugh Cayless
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With PhpJeremy Coates
 
WordPress Queries - the right way
WordPress Queries - the right wayWordPress Queries - the right way
WordPress Queries - the right wayAnthony Hortin
 
Fixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan ChepurnyiFixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan ChepurnyiMeet Magento Spain
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3Javier Eguiluz
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介Jace Ju
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxMichelangelo van Dam
 

La actualidad más candente (20)

Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Images and PWA in magento
Images and PWA in magentoImages and PWA in magento
Images and PWA in magento
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
How Can I tune it When I Can't Change the Code?
How Can I tune it When I Can't Change the Code?How Can I tune it When I Can't Change the Code?
How Can I tune it When I Can't Change the Code?
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for Magento
 
AMD & Require.js
AMD & Require.jsAMD & Require.js
AMD & Require.js
 
Bringing Characters to Life for Immersive Storytelling - Dioselin Gonzalez
Bringing Characters to Life for Immersive Storytelling - Dioselin GonzalezBringing Characters to Life for Immersive Storytelling - Dioselin Gonzalez
Bringing Characters to Life for Immersive Storytelling - Dioselin Gonzalez
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
Krazykoder struts2 plugins
Krazykoder struts2 pluginsKrazykoder struts2 plugins
Krazykoder struts2 plugins
 
Nashvile Symfony Routes Presentation
Nashvile Symfony Routes PresentationNashvile Symfony Routes Presentation
Nashvile Symfony Routes Presentation
 
Bringing characters to life for immersive storytelling
Bringing characters to life for immersive storytellingBringing characters to life for immersive storytelling
Bringing characters to life for immersive storytelling
 
Wordpress plugin development from Scratch
Wordpress plugin development from ScratchWordpress plugin development from Scratch
Wordpress plugin development from Scratch
 
Rebooting TEI Pointers
Rebooting TEI PointersRebooting TEI Pointers
Rebooting TEI Pointers
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
 
WordPress Queries - the right way
WordPress Queries - the right wayWordPress Queries - the right way
WordPress Queries - the right way
 
Fixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan ChepurnyiFixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan Chepurnyi
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
 
New tags in html5
New tags in html5New tags in html5
New tags in html5
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 

Similar a Best Practices for Custom Apps in SugarCRM

Getting started with MongoDB and PHP
Getting started with MongoDB and PHPGetting started with MongoDB and PHP
Getting started with MongoDB and PHPgates10gen
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel MakhrinskyDrupalCampDN
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To LampAmzad Hossain
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
Php Basic Security
Php Basic SecurityPhp Basic Security
Php Basic Securitymussawir20
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management SystemValent Mustamin
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentationipolevoy
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Coursemussawir20
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplicationolegmmiller
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kianphelios
 
State Machines to State of the Art
State Machines to State of the ArtState Machines to State of the Art
State Machines to State of the ArtRowan Merewood
 

Similar a Best Practices for Custom Apps in SugarCRM (20)

What's New in ZF 1.10
What's New in ZF 1.10What's New in ZF 1.10
What's New in ZF 1.10
 
Getting started with MongoDB and PHP
Getting started with MongoDB and PHPGetting started with MongoDB and PHP
Getting started with MongoDB and PHP
 
Views notwithstanding
Views notwithstandingViews notwithstanding
Views notwithstanding
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel Makhrinsky
 
Mojolicious on Steroids
Mojolicious on SteroidsMojolicious on Steroids
Mojolicious on Steroids
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To Lamp
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
PHP Unit Testing
PHP Unit TestingPHP Unit Testing
PHP Unit Testing
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
 
Php Basic Security
Php Basic SecurityPhp Basic Security
Php Basic Security
 
I Love codeigniter, You?
I Love codeigniter, You?I Love codeigniter, You?
I Love codeigniter, You?
 
Framework
FrameworkFramework
Framework
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management System
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Course
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
 
State Machines to State of the Art
State Machines to State of the ArtState Machines to State of the Art
State Machines to State of the Art
 
Perl Dancer, FPW 2010
Perl Dancer, FPW 2010Perl Dancer, FPW 2010
Perl Dancer, FPW 2010
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
 

Más de John Mertic

The Virtual Git Summit - Subversion to Git - A Sugar Story
The Virtual Git Summit - Subversion to Git - A Sugar StoryThe Virtual Git Summit - Subversion to Git - A Sugar Story
The Virtual Git Summit - Subversion to Git - A Sugar StoryJohn Mertic
 
PHPBenelux 2012 - Working successfully outside the cube
PHPBenelux 2012 - Working successfully outside the cubePHPBenelux 2012 - Working successfully outside the cube
PHPBenelux 2012 - Working successfully outside the cubeJohn Mertic
 
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...John Mertic
 
Astricon 2011 - Connecting SugarCRM with your PBX
Astricon 2011 - Connecting SugarCRM with your PBXAstricon 2011 - Connecting SugarCRM with your PBX
Astricon 2011 - Connecting SugarCRM with your PBXJohn Mertic
 
OSCON 2011 - Building An Application On The SugarCRM Platform
OSCON 2011 - Building An Application On The SugarCRM PlatformOSCON 2011 - Building An Application On The SugarCRM Platform
OSCON 2011 - Building An Application On The SugarCRM PlatformJohn Mertic
 
OSCON 2011 - Making Your PHP Application Easy to Customize
OSCON 2011 - Making Your PHP Application Easy to CustomizeOSCON 2011 - Making Your PHP Application Easy to Customize
OSCON 2011 - Making Your PHP Application Easy to CustomizeJohn Mertic
 
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...John Mertic
 
Making Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux ConferenceMaking Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux ConferenceJohn Mertic
 
SugarCON 2009 - Theme Development in Sugar 5.5
SugarCON 2009 - Theme Development in Sugar 5.5SugarCON 2009 - Theme Development in Sugar 5.5
SugarCON 2009 - Theme Development in Sugar 5.5John Mertic
 
Developing Easily Deployable PHP Applications ( OSCON 2010 )
Developing Easily Deployable PHP Applications ( OSCON 2010 )Developing Easily Deployable PHP Applications ( OSCON 2010 )
Developing Easily Deployable PHP Applications ( OSCON 2010 )John Mertic
 
SugarCon 2010 - Sugar as a Business Application Framework
SugarCon 2010 - Sugar as a Business Application Framework SugarCon 2010 - Sugar as a Business Application Framework
SugarCon 2010 - Sugar as a Business Application Framework John Mertic
 
2009 Ontario GNU Linux Fest - Build your business on SugarCRM
2009 Ontario GNU Linux Fest - Build your business on SugarCRM2009 Ontario GNU Linux Fest - Build your business on SugarCRM
2009 Ontario GNU Linux Fest - Build your business on SugarCRMJohn Mertic
 

Más de John Mertic (12)

The Virtual Git Summit - Subversion to Git - A Sugar Story
The Virtual Git Summit - Subversion to Git - A Sugar StoryThe Virtual Git Summit - Subversion to Git - A Sugar Story
The Virtual Git Summit - Subversion to Git - A Sugar Story
 
PHPBenelux 2012 - Working successfully outside the cube
PHPBenelux 2012 - Working successfully outside the cubePHPBenelux 2012 - Working successfully outside the cube
PHPBenelux 2012 - Working successfully outside the cube
 
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
 
Astricon 2011 - Connecting SugarCRM with your PBX
Astricon 2011 - Connecting SugarCRM with your PBXAstricon 2011 - Connecting SugarCRM with your PBX
Astricon 2011 - Connecting SugarCRM with your PBX
 
OSCON 2011 - Building An Application On The SugarCRM Platform
OSCON 2011 - Building An Application On The SugarCRM PlatformOSCON 2011 - Building An Application On The SugarCRM Platform
OSCON 2011 - Building An Application On The SugarCRM Platform
 
OSCON 2011 - Making Your PHP Application Easy to Customize
OSCON 2011 - Making Your PHP Application Easy to CustomizeOSCON 2011 - Making Your PHP Application Easy to Customize
OSCON 2011 - Making Your PHP Application Easy to Customize
 
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
 
Making Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux ConferenceMaking Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux Conference
 
SugarCON 2009 - Theme Development in Sugar 5.5
SugarCON 2009 - Theme Development in Sugar 5.5SugarCON 2009 - Theme Development in Sugar 5.5
SugarCON 2009 - Theme Development in Sugar 5.5
 
Developing Easily Deployable PHP Applications ( OSCON 2010 )
Developing Easily Deployable PHP Applications ( OSCON 2010 )Developing Easily Deployable PHP Applications ( OSCON 2010 )
Developing Easily Deployable PHP Applications ( OSCON 2010 )
 
SugarCon 2010 - Sugar as a Business Application Framework
SugarCon 2010 - Sugar as a Business Application Framework SugarCon 2010 - Sugar as a Business Application Framework
SugarCon 2010 - Sugar as a Business Application Framework
 
2009 Ontario GNU Linux Fest - Build your business on SugarCRM
2009 Ontario GNU Linux Fest - Build your business on SugarCRM2009 Ontario GNU Linux Fest - Build your business on SugarCRM
2009 Ontario GNU Linux Fest - Build your business on SugarCRM
 

Último

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Último (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Best Practices for Custom Apps in SugarCRM

  • 1. 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 1
  • 2. Best Practices for Creating Custom Apps in Sugar John Mertic SugarCRM 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 2
  • 3. The golden rules of customizations Use Module Builder/Studio for customizations if possible Otherwise, put your code inside the custom directory 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 3
  • 4. Why do this? Module Builder/Studio changes are well supported and easier to manage Customizations are separated from the shipped code Allows you to manage your customizations via version control ( SVN, Git, etc ) Files in here aren’t disturbed by any Sugar upgrades Exception – sometimes we will try to fix metadata templates on upgrades for new/removed fields. Makes your app “Upgrade Safe” 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 4
  • 5. Exceptions to this… New modules need to be under modules/ directory. Bean class customizations to OOTB modules need to be on the original bean file. We’ll look at using logic hooks and other techniques to avoid this for many use cases. Will need to manually manage this during upgrades, so best to avoid. 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 5
  • 6. Let’s see what we can do 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 6
  • 7. MVC Framework MVC stands for Model View Controller 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 7
  • 8. MVC Framework – The anatomy of a request 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 8
  • 9. MVC Framework – SugarApplication Bootstraps the application Loads many of the default application settings Language Theme Session Handles User Authentication Loads the controller 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 9
  • 10. MVC Framework - SugarController Manages all the actions of a module Contains logic for handling requests that don’t require a view Example: Record saving Maps all other requests to the correct view Logic for mapping an action of one name to a view of another Can detect if we should be using MVC or classic views 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 10
  • 11. MVC Framework – SugarController API 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 11
  • 12. MVC Framework – Controller Example 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 12 <?php class ExampleController extends SugarController { public function action_hello() { echo "Hello World!"; } public function action_goodbye() { $this->view = 'goodbye'; } }
  • 13. MVC Framework – Controller-less mapping If your module doesn’t need to have any controller logic, use action mapping insteads. Create file named action_view_map.php with the following contents: 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 13 <?php $action_view_map['goodbye'] = 'goodbye';
  • 14. MVC Framework - SugarView Contains the display logic for the action Uses a metadata backend for Edit, Detail, List, Popup views And Convert Lead in Sugar 6.0 For other views, you write the code for the view and put it in modules/modulename/views/view.viewname.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 14
  • 15. MVC Framework – SugarView API 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 15
  • 16. MVC Framework – SugarView API 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 16
  • 17. MVC Framework – View Example 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 17 <?php class ViewExample extends SugarView { public function preDisplay() { if ( !is_admin($GLOBALS["current_user"]) ) sugar_die("Not an Admin"); } public function display() { echo "Hello Admin!"; } }
  • 18. MVC Framework – ViewDetail Example 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 18 <?php require_once('include/MVC/View/views/view.detail.php'); class ContactsViewDetail extends ViewDetail { public function display() { $admin = new Administration(); $admin->retrieveSettings(); if(isset($admin->settings['portal_on']) && $admin->settings['portal_on']) { $this->ss->assign("PORTAL_ENABLED", true); } parent::display(); } }
  • 19. 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 19 Where do I put my customizations? Controllers /custom/modules/Modulename/controller.php class CustomModulenameController extends SugarController Views /custom/modules/Modulename/views/view.viewname.php class CustomModulenameViewViewname extends ModulenameViewViewname If that class doesn’t exist extend from ViewViewname or SugarView
  • 20. Metadata Layer 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 20
  • 21. Kinds of metadata editviewdefs.php / detailviewdefs.php / quickcreatedefs.php Wireless variants: wireless.editviewdefs.php, wireless.detailviewdefs.php subpaneldefs.php listviewdefs.php wireless.listviewdefs.php searchdefs.php wireless.searchdefs.php SearchFields.php popupdefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 21
  • 22. editviewdefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 22 <?php $viewdefs[$module_name]['EditView'] = array( 'templateMeta' => array( 'maxColumns' => '2', 'widths' => array( array('label' => '10', 'field' => '30'), array('label' => '10', 'field' => '30'), ), ), 'panels' =>array ( 'default' => array ( array ( 'name', 'assigned_user_name', ), array(array( 'name' => 'date_modified', 'customCode' => '{$fields.date_modified.value} {$APP.LBL_BY} {$fields.modified_by_name.value}', 'label' => 'LBL_DATE_MODIFIED', )), ), array( array ( 'description', ), ), ), );
  • 23. subpaneldefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 23 <?php $layout_defs[$module_name] = array( 'subpanel_setup' => array( 'contacts' => array( 'order' => 20, 'module' => 'Contacts', 'sort_by' => 'last_name, first_name', 'sort_order' => 'asc', 'subpanel_name' => 'default', 'get_subpanel_data' => 'contacts', 'title_key' => 'LBL_CONTACTS_SUBPANEL_TITLE', 'top_buttons' => array( array('widget_class' => 'SubPanelTopButtonQuickCreate'), array( 'widget_class'=>'SubPanelTopSelectButton', 'mode'=>'MultiSelect’ ), ), ), ), );
  • 24. searchdefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 24 <?php $searchdefs[$module_name] = array( 'templateMeta' => array( 'maxColumns' => '3', 'widths' => array('label' => '10', 'field' => '30'), ), 'layout' => array( 'basic_search' => array( 'name', array('name'=>'current_user_only', 'label'=>'LBL_CURRENT_USER_FILTER', 'type'=>'bool'), ), 'advanced_search' => array( 'name', array('name' => 'phone', 'label' =>'LBL_ANY_PHONE', 'type' => 'name'), array('name' => 'address_city', 'label' =>'LBL_CITY', 'type' => 'name'), array('name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name'), array('name' => 'assigned_user_id', 'type' => 'enum', 'label' => 'LBL_ASSIGNED_TO', 'function' => array('name' => 'get_user_array', 'params' => array(false))), ), ), );
  • 25. SearchFields.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 25 <?php $searchFields[$module_name] = array ( 'name' => array( 'query_type'=>'default'), 'current_user_only'=> array('query_type'=>'default', 'db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'), 'assigned_user_id'=> array('query_type'=>'default'), );
  • 26. popupdefs.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 26 <?php global $mod_strings; $popupMeta = array( 'moduleMain' => 'Account', 'varName' => 'ACCOUNT', 'orderBy' => 'name', 'whereClauses' => array( 'name' => 'accounts.name', 'billing_address_city' => 'accounts.billing_address_city', 'phone_office' => 'accounts.phone_office'), 'searchInputs' => array('name', 'billing_address_city', 'phone_office'), 'create' => array( 'formBase' => 'AccountFormBase.php', 'formBaseClass' => 'AccountFormBase', 'getFormBodyParams' => array('','','AccountSave'), 'createButton' => $mod_strings['LNK_NEW_ACCOUNT’]), 'listviewdefs' => array( 'NAME' => array( 'width' => '40', 'label' => 'LBL_LIST_ACCOUNT_NAME', 'link' => true,'default' => true,), ), 'searchdefs' => array( 'name', array('name' => 'assigned_user_id', 'label'=>'LBL_ASSIGNED_TO', 'type' => 'enum', 'function' => array('name' => 'get_user_array', 'params' => array(false))), ),);
  • 27. Where do I put my customizations? Subpaneldefs custom/Extension/modules/Modulename/Ext/Layoutdefs/NameWhateverYouWant.php Need to run ‘Quick Repair and Rebuild’ after changes are made Everything else /custom/modules/Modulename/metadata Watch for Studio blowing out your changes. 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 27
  • 28. Logic Hooks 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 28
  • 29. Logic Hook Types 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 29
  • 30. Logic Hook Types (cont) 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 30
  • 31. Logic Hook Types (new in 6.0) 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 31
  • 32. logic_hooks.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 32 <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array(1, 'AccountHooks', 'custom/Accounts/AccountHooks.php','AccountHooks', 'getParentAccountIndustry'); Parameters for Logic Hook Definition Parameter 1 - Sorting index used to sort the arrays of logic hook definitions before they are processed.Parameter 2 - A string value to identify the hookParameter 3 - Path to the PHP file to include which contains your logic hook codeParameter 4 - Name of the PHP class the logic hook method is inParameter 5 - Name of the PHP method to call
  • 33. AccountHooks.php 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 33 <?php class AccountHooks { public function getParentAccountIndustry( SugarBean $bean, $event, $arguments ) { if ( empty($bean->industry) && !empty($bean->parent_id) ) { $parentAccountFocus = new Account(); $parentAccountFocus->retrieve($bean->parent_id); if ( !empty($parentAccountFocus->id) ) $bean->industry = $parentAccountFocus->industry; } } }
  • 34. Where do I put my customizations? Application Level Logic Hooks /custom/modules/ Module Level Logic Hooks /custom/modules/Modulename/ 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 34
  • 35. Themes 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 35
  • 36. Theme Directory Layout css/ - contains all css files images/ - contains all images js/ - contains any js files. tpls/ - smarty templates themedef.php definition file. 12/30/08 ©2009 SugarCRM Inc. All rights reserved. 36
  • 37. Themes can inherit from other themes Theme Inheritance Model 12/30/08 ©2009 SugarCRM Inc. All rights reserved. 37
  • 38. Allow upgrade-safe modifications to themes All themes can be modified by putting the replacement or overriding file in the custom/theme/<themename> directory Image, HTML template file overrides are used as a replacement of the previous file Example: an image custom/theme/<themename>/dog.gif would be used instead of theme/<themename>/dog.gif CSS and Javascript files are combined in order of inheritance Uses cssmin and jsmin to help reduce file size No further code changes are required – changes are picked up automatically when themes cache is rebuilt. 12/30/08 ©2009 SugarCRM Inc. All rights reserved. 38
  • 39. Resources 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 39 http://developers.sugarcrm.com Buy my book!
  • 40. Thanks for coming! 4/14/10 ©2010 SugarCRM Inc. All rights reserved. 40