Author avatar for jason

How to Package Version Specific Code

Posted by on January 17, 2013

When we recently added a feature to our upload scanner that checks the module zip for any missing files we unintentionally found a hidden gem. As many of you are familiar with, sometimes you just have to make a change that is specific to a certain version of SugarCRM. What many do in a case like that is to provide a zip file for that specific version (e.g. This can become hard to maintain over time.

Christian Knoll (creator of the Google StyleTheme) has a very clever way of dealing with this. In the manifest he takes advantage of the sugar_flavor and sugar_version global variables. Using these he is able to dynamically define what files to copy over based on the user’s current version.

So instead of a zip for each version, we are able to define what flavors and versions to support:

Then in the copy we can utilize the global vars:

This would then pull the appropriate version from the module zip’s file structure:

..and so on

This makes it much easier to maintain for multiple versions and flavors of SugarCRM. Unfortunately, it means we have some work to do to add support to the upload scanner for this method. Thanks Christian!

Like this post?

We'll send you an email once a month with the latest posts.

Keep up to date on the latest additions

We'll send you an email every month with handpicked add-ons, reviews, tricks and tips. Don't worry, we hate spam as much as you do.