如何创建一个结合了2个细节视图的SugarCRM视图

dki*_*zer 2 sugarcrm

我想扩展联系人详细信息视图,以便相关帐户的详细信息视图显示在同一视图中.

我的直觉是覆盖"联系人详细信息视图"的显示功能,然后从中创建"帐户详细信息"的实例并附加其显示输出.

但我不知道是否有一种标准的拉动方式.

dki*_*zer 6

我了解到,在即将到来的版本(6.3)中,将有一种生成计算字段的方法,这些字段可以访问相关模块的字段.

如果是这种情况,那么一个选项是创建引用帐户字段的计算字段,然后使用引用的帐户字段将面板添加到Contact DetailView.

虽然,我原来的预感被证明是可行的,而不是像我最初假设的那样hacky:

<?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();
    }
  }
?>
Run Code Online (Sandbox Code Playgroud)

综上所述

  1. 覆盖详细信息视图.
  2. 将新显示添加到当前视图.
  3. 将新bean(模块)添加到View.
  4. 使用新bean处理显示.
  5. 回显显示.