开发者

How does one create a SugarCRM View that combines 2 Detail Views

I would like to extend the Contact Detail View so that a Detail View of the associated account开发者_如何学Go appears on the same view.

MY instinct is to override the display function for the Contacts Detail View and from there create an instance of the Accounts Detail and attach it's display output.

But I don't know if there is a standard way of pulling this of.


I learned that in the up coming version (6.3), there will be a way of generating computed fields that have access to the fields of a related module.

If this is the case, then one option will be to create computed fields that reference the Account fields and then add a panel to Contact DetailView with the referenced Account fields.

Though, my original hunch proved to be doable as well and not as hacky as I had assumed at first:

<?php
  require_once('include/MVC/View/views/view.detail.php');

  class ContactsViewDetail extends ViewDetail {

    function ContactsViewDetail() {
      parent::ViewDetail();
    }

    function preDisplay(){
      parent::preDisplay();
      // Configuration to display All account info
      $this->dv2 = new DetailView2();
      $this->dv2->ss =& $this->dv->ss;
      $this->bean2 = new Account();
      $this->bean2->retrieve($this->bean->account_id);
      $accountMetadataFile = 'custom/modules/Accounts/metadata/detailviewdefs.php';
      $accountTemplate = 'custom/modules/Accounts/tpls/AccountsDetailView.tpl';
      $this->dv2->setup('Accounts', $this->bean2, $accountMetadataFile, $accountTemplate);
    }

    function display(){
      parent::display();

      // Display Accounts information.
      $this->dv2->process();
      echo $this->dv2->display();
    }
  }
?>

In summary

  1. Override the detail view.
  2. Add a new display to the current View.
  3. Add a new bean (module) to the View.
  4. Process the display with the new bean.
  5. Echo the display.


Another easier option may be just add an iframe field, which loads the detailview on the account inside of it. Not as pretty, but lots less hacking as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜