Suitecrm自定义模块的自定义模板

时间:2016-08-11 10:06:54

标签: sugarcrm suitecrm

我使用模块构建器构建了一个自定义模块。

我想修改模块的模板(编辑,细节,子面板)。

如何告诉Suitecrm使用其他模板?

由于

(Suitecrm 7.7)

2 个答案:

答案 0 :(得分:1)

它为我工作。

<?php

require_once('include/MVC/View/SugarView.php');

class AccountsViewEdit extends SugarView {

private $smarty;

  public function __construct() {

  }

  public function display() {
    $this->smarty = new Sugar_Smarty();
    $data = ['a'=> 'a', 'b'=>'b'];
    $this->smarty->assign($data);
    $this->smarty->display('path/custom/template.tpl');        
  }
}

答案 1 :(得分:0)

您需要在模块中创建SugarView,然后覆盖display()方法以返回自定义模板的路径。惯例是将模板保存在模块中的“tpl”文件夹中。

例如,如果您查看'modules / Accounts / views / view.edit.php',您只需要添加

class AccountsViewEdit extends ViewEdit
{
    public function __construct()
    {
        parent::__construct();
        $this->useForSubpanel = true;
        $this->useModuleQuickCreateTemplate = true;
    }

    public function display() {

        parent::display(); // TODO: Change the autogenerated stub
        return $this->ss->fetch('path/to/your/smarty/template.tpl');
    }
}

除了位置在Dashlets文件夹中之外,子面板几乎相同。例如,查看modules / Accounts / Dashlets / MyAccountsDashlet / MyAccountsDashlet.php。