Archive for the ‘Tip’ Category

GPLv3 Analysis from 451 Group

Friday, February 15th, 2008

GPLv3 Q&A doesn’t seem like the hot topic we expected it to be. Andy Dreisch presented at SugarCON on the ramifications of GPLv3 on Sugar. I think from the tone of his post he left his presentation under-whelmed by the response (or lack thereof).

For those of you who could not attend Andy’s session, but want to be part of the GPLv3 discussion - The 451 Group is hosting a webinar on Feb 20th, complete with Q&A. I recommend that you attend if you want to understand the future of GPL and the Open Source.

Technorati Tags: ,

Valentine’s Vardef

Thursday, February 14th, 2008

Heart 20080214121354 52954 In honor of Valentine’s Day:

Rose are red,
Violets are blue,
Don’t know about vardefs?
Then you’re probably screwed.

I love the concept of vardefs. Simply put, Vardefs is a multi-dimensional array in PHP for each module that contains the attributes, properties, and metadata about each field/column in the database. Each vardefs file is located in it’s parent module. Jacob and Ken and probably countless others have document this well on the wiki and in the forums.

So, how practical is the information? Well it comes up all of the time - people want to make stock fields required or audited that aren’t already that way. Here’s an example from the Contacts Module. The use case is that I want to make the birth date field in Contacts, required (in the change log). This comes to us from ./modules/Contacts/vardefs.php:

	‘birthdate’ =>
		array (
			‘name’ => ‘birthdate’,
			‘vname’ => ‘LBL_BIRTHDATE’,
			‘massupdate’ => false,
			‘type’ => ‘date’,
			‘comment’ => ‘The birthdate of the contact’,
			// Added below code to make it required
			‘required’ => true,
		),

That’s it, just refresh the page and it is now a required field subject to JS client-side validation.

Additionally you can add alter the db in the vardefs file as necessary. A quick “Rebuild Database” in Admin >> Repair >> Rebuild Database and away ya go!

Technorati Tags: , ,

Deploy, Publish, Export

Tuesday, February 12th, 2008

If you’re like me you sometimes find the Module Builder terminology of “Deploy”, “Publish” and “Export” a little fuzzy.

This article summarizes the terminology nicely.

Code snippet on changing the size of Text Areas

Tuesday, February 12th, 2008

A community member asked in the forums yesterday how to customize the height and width of a text area in the Edit View layout. With the new MVC UI framework in Sugar 5.0, you no longer edit the Xtemplate html file directly like you did in 4.5 but rather modify the editviewdefs.php file for the form you want to change.

Here is an example where you create a custom field, place it on the Edit View and Detail View forms and then manually edit the resulting editviewdefs.php to change the size of the Text Area. This example also shows you how to use the maxlength parameter to limit the amount of text that can be added to the text area. For you HTML junkies out there, you know that this is a custom JS function found in the Sugar UI framework that limits the text entered as the standard HTML textarea tag doesn’t have such a parameter.

 

Example:
1) Create a new custom TextArea field in the Opportunities module using Sugar Studio.
2) Add the custom field to the EditView and the DetailView layouts by adding a new row to the bottom of the layouts and then dropping the field onto the screen. NOTE: Be sure to remove the second filler field from the new row you added so that the new custom field will span across the two columns.
3) Save and deploy the changes to both layouts.
4) Now open in a text editor the new file custom/modules/Opportunities/metadata/editviewdefs.php.
5) Find the Comments field definition and modify it to include the new displayParams parameter below:

array (
‘name’ => ‘comments_c’,
‘label’ => ‘LBL_COMMENTS’,
‘displayParams’=>array(‘rows’=>20, ‘cols’=>80, ‘maxlength’=>350),
),

Oracle and The Future

Monday, February 11th, 2008

Did you hear the rumors that SFDC offered itself to Oracle? Maybe it makes sense for Oracle and SFDC, but does it make sense for developers, the community, and customers?

Tom Foremski says that the two businesses are easily integrated because they’re based on standards. Maybe SFDC actually uses HTML, but APEX is far from an industry standard. How does that help the developer community and ultimately the customers / end-users?

Of course I am an open source advocate and a devoted MySQL user, but Oracle is a stellar database that scales. As a developer and also as the Advanced Support Manager for Sugar, I often find myself working with enterprise organizations that are Oracle shops. So why get stuck with APEX when you can have REAL open standards and flexibility?

If you’re going to develop for Sugar and you’re going to use Oracle - I *HIGHLY* recommend Zend Core for Oracle. It makes installation and maintenance and fine-tuning SOOO easy. My favorite part is that it’s FREE!

I’ve also learned that once you’ve installed Zend Core for Oracle, it would behoove you to upgrade to the latest oci8_client that comes with PHP. PHP 5.2.x+ has the best oci8 client from my personal experience.

What do you think about Oracle and its future? What tips have you learned as a PHP developer and from working with Oracle?

Logic Hooks and Workflow

Friday, February 8th, 2008

Whoa am I tired. It’s been a non-stop whirlwind of shaking hands, answering questions, presentations, and fun. Lots and lots of fun.

At the request of many of you who, I’m posting on the logic hooks and workflow presentations.

Let’s get down to brass tacks - do you know what or where the logic hooks are in SugarCRM? If you don’t, you need to watch this video and bookmark this page.

Workflow is just a glorified logic hook. A lot of the time, I find that I get about 95% of the way with workflow, but it just doesn’t do the last 5% within the workflow UI. However, if I just tried to write a custom logic hook, it would take me longer than if could get that last 5%. Thankfully (wonderfully), Sugar is Open Source, so it’s simple to just split off a workflow and then customize it for the business.

Steps to split a workflow off to a custom logic hook:

Step 1: copy ./include/workflow/WorkFlowHandler.php to ./custom/include/workflow/ (create the directory, it won’t exist)

Step 2: edit the ./custom/include/workflow/WorkFlowHander.php

Step 2a: Rename WorkFlowHandler class to WorkFlowCustomHandler

Step 2b: change all references to the workflow directory to workflow_cstm

Step 2c: change all references to $target_class to $target_class = $focus->module_dir.”_workflow_cstm”;

Step 3: Edit the logic_hook.php file in the target module (ie: ./custom/modules/Accounts/logic_hook.php)

Step 3a: Add another $hook_array pointing to (./custom/include/workflow/WorkFlowHandler.php).

Step 3b: Make sure the $hooks_array calls the new WorkFlowCustomHandler class (see the video, if you’re lost right now)

Step 4: Copy the workflow directory to workflow_cstm, (ie: ./custom/modules/Accounts/workflow_cstm

Step 5: Change all references to the includes for the workflow directory to workflow_cstm directory. For example:

include('custom/modules/Accounts/workflow_cstm/triggers_arrays.php);
include('custom/modules/Accounts/workflow_cstm/action_arrays.php;

Step 6: Alter workflow.php to your desired behavior (ie: ./custom/modules/Accounts/workflow_cstm/workflow.php);

That’s it folks. Workflow just got split off. Word to the wise though - DELETE the workflow in the UI. Every time the definition saves, it will save the workflow.php. Best to delete it and log it elsewhere that you’ve created a logic_hook.

So you have all the power of workflow, plus more. And - it’s upgrade safe!

Extensions to the User Page

Tuesday, January 22nd, 2008

Check out this forum thread that talks about how to extend the User page in an upgrade-safe way.

MVC and Metadata Framework in SugarCRM Release 5.0

Saturday, January 12th, 2008

Check out this new addition to the Developer Start section for a design and implementation description of release 5.0 MVC and Metadata UI framework. The SugarCRM Wiki article also offers some guidance on how to customize your application in this environment. Be sure to visit the Developer Start section frequently for updates and new useful resources.

Know Your Resources

Friday, January 11th, 2008

Did you know… if you add the following code below to your config_override.php, you will be able to how many resources it took to build a page?

$sugar_config['show_page_resources'] = true;

You’ll find this at the base of every page output:

Resources used to construct this page (queries, files)(14,156)
External cache (hits/total=ratio) local (2/26=8%)

How cool is that?

Writing and Rewriting Faster Code in Sugar

Thursday, January 10th, 2008

Sometimes code just doesn’t scale.

One of my favorite tools to keep the code I am writing fast and scalable is xdebug. When I found that Zend Developer Zone did a four part series on xdebug, I felt compelled to pass it along. This article is specific to profiling code:

http://devzone.zend.com/article/2899-Profiling-PHP-Applications-With-xdebug

The above article also highlights some of the tools for analyzing cachegrind files. I’ve searched, but nothing exists to analyze cachegrind files on Mac OS X. If you know of something, post it here!

xDebug does much more than just profiling, so check it out.

Have feedback for us? Drop us a line.
Terms & Conditions | Privacy | Trademark Info | Contact Info | FAQs | SugarCRM Inc.© 2004 - 2008 All rights reserved.