SlideShare a Scribd company logo
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

More Related Content

What's hot

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
Gordon Forsythe
 
Images and PWA in magento
Images and PWA in magentoImages and PWA in magento
Images and PWA in magento
Rrap Software Pvt Ltd
 
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
Tammy 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 Magento
Ivan Chepurnyi
 
AMD & Require.js
AMD & Require.jsAMD & Require.js
AMD & Require.js
Eyal 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 Gonzalez
WithTheBest
 
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 plugins
Krazy Koder
 
Nashvile Symfony Routes Presentation
Nashvile Symfony Routes PresentationNashvile Symfony Routes Presentation
Nashvile Symfony Routes Presentation
Brent 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 storytelling
Dioselin Gonzalez
 
Wordpress plugin development from Scratch
Wordpress plugin development from ScratchWordpress plugin development from Scratch
Wordpress plugin development from Scratch
Ocaka Alfred
 
Rebooting TEI Pointers
Rebooting TEI PointersRebooting TEI Pointers
Rebooting TEI Pointers
Hugh Cayless
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
Jeremy Coates
 
WordPress Queries - the right way
WordPress Queries - the right wayWordPress Queries - the right way
WordPress Queries - the right way
Anthony 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 Chepurnyi
Meet Magento Spain
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
Javier Eguiluz
 
New tags in html5
New tags in html5New tags in html5
New tags in html5
SathyaseelanK1
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介
Jace Ju
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
Michelangelo van Dam
 

What's hot (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 to SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar

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
Ralph Schindler
 
Getting started with MongoDB and PHP
Getting started with MongoDB and PHPGetting started with MongoDB and PHP
Getting started with MongoDB and PHP
gates10gen
 
Views notwithstanding
Views notwithstandingViews notwithstanding
Views notwithstanding
Srikanth Bangalore
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel Makhrinsky
DrupalCampDN
 
Mojolicious on Steroids
Mojolicious on SteroidsMojolicious on Steroids
Mojolicious on Steroids
Tudor Constantin
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To Lamp
Amzad 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 Framework
Dirk Haun
 
PHP Unit Testing
PHP Unit TestingPHP Unit Testing
PHP Unit Testing
Tagged Social
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
Anil Kumar Panigrahi
 
Php Basic Security
Php Basic SecurityPhp Basic Security
Php Basic Security
mussawir20
 
I Love codeigniter, You?
I Love codeigniter, You?I Love codeigniter, You?
I Love codeigniter, You?
إسماعيل عاشور
 
Framework
FrameworkFramework
Framework
Nguyen Linh
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management System
Valent Mustamin
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Course
mussawir20
 
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
olegmmiller
 
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
phelios
 
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
Rowan Merewood
 
Perl Dancer, FPW 2010
Perl Dancer, FPW 2010Perl Dancer, FPW 2010
Perl Dancer, FPW 2010
Alexis Sukrieh
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
Alfresco Software
 

Similar to SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar (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
 

More from 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 Story
John 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 cube
John 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 PBX
John 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 Platform
John 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 Customize
John 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 Conference
John 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.5
John 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 SugarCRM
John Mertic
 

More from 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
 

Recently uploaded

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 

Recently uploaded (20)

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 

SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar

  • 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