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

时间:2011-09-23 16:11:49

标签: sugarcrm

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

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

但我不知道是否有一种标准方法可以解决这个问题。

2 个答案:

答案 0 :(得分: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();
    }
  }
?>

总结

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

答案 1 :(得分:1)

另一个更简单的选项可能只是添加一个iframe字段,该字段在其内部的帐户中加载详细信息视图。不是那么漂亮,但也很少被黑客攻击。