Multiple DetailViews for the Same Module

This past September Francesca from the SugarCRM forums asked if there was a way to have a different layout view for each department:

two different Edit Views and two different Detail Views for the SAME module?

The short answer is yes. SugarCRM lets you do just about anything. The question always is – at what cost and/or tradeoff?

To do this for a module (like the Accounts module) copy custom/metadata/Accounts/metadata/detailviewdefs.php and rename for each department. For example, custom/metadata/Accounts/metadata/detailviewdefs_sales.php. Then create a custom view.detail.php and tell SugarCRM to use the appropriate custom layout:

Caveat – you must turn on developerMode. Otherwise, it will just cache the first requested layout and every subsequent request will use that same cache/modules/Accounts/DetailView.tpl. With this code, we need that .tpl rebuilt on every request. Actually, thinking about this more it really does have some annoying limitations:

  • Can’t take advantage of cache.
    Result = performance degradation.
  • Can’t use Studio to edit the custom layouts.
    Result = time consuming code changes.
  • Has to be done for any and every module required and for every department.
    Result = more time consuming work.

I didn’t start writing this post with this intention, but it is clear that if you really want custom layouts just use my SecuritySuite module. Even if you don’t need the teams security portion, the custom layouts feature by itself makes doing this a breeze.

Result = saving time, money, and frustration.

Then again, it may be good enough for a one-time thing.

Update: Angel (check out his awesome blog!) has noted that the cache can also be cleared on demand using:

TemplateHandler::clearCache('Accounts','DetailView.tpl');

This removes the need to turn on developerMode and reduces the lack of caching just to that view in that specific module.

about

I make high quality solutions at an alarming rate.

Trackbacks/Pingbacks

  1. Adding Dynamic Tabs and Contents in a Module - July 10, 2013

    […] for your leads module. there is an article by eggsurplus regarding this customization. Multiple DetailViews for the Same Module | eggsurplus solutions Hope this […]

Leave a Reply