我已经创建了一个模块并命名为:Custom_module 通过 Developer Tools --> Module Builder 我尝试将“目标列表”添加到 Custom_module,例如模块 Campaign,但我找不到这样做的方法 每个人都可以帮助您找到将“目标列表”添加到我的模块的最佳方法。 谢谢
最佳答案
您只需在您的自定义模块
中创建一个自定义子面板
。
目标列表
是ProspectLists
模块。
点击此链接创建自定义模块。
http://shanedowling.com/sugarcrm-7-custom-subpanels
https://developer.sugarcrm.com/2015/05/18/creating-subpanels-with-custom-results-in-sugar-7-5/
<强>1。创建一个新的链接类
这应该进入 custom/modules//YourNewLink.php 并且此类将作为自定义功能,在两个记录之间建立链接。
<?php
/**
* Custom filtered link
*/
class YourNewLink extends Link2
{
/**
* DB
*
* @var DBManager
*/
protected $db;
public function __construct($linkName, $bean, $linkDef = false)
{
$this->focus = $bean;
$this->name = $linkName;
$this->db = DBManagerFactory::getInstance();
if (empty($linkDef)) {
$this->def = $bean->field_defs[$linkName];
} else {
$this->def = $linkDef;
}
}
/**
* Returns false if no relationship was found for this link
*
* @return bool
*/
public function loadedSuccesfully()
{
// this link always loads successfully
return true;
}
/**
* @see Link2::getRelatedModuleName()
*/
public function getRelatedModuleName()
{
return '<Your_Module>';
}
/**
*
* @see Link2::buildJoinSugarQuery()
*/
public function buildJoinSugarQuery($sugar_query, $options = array())
{
$joinParams = array('joinType' => isset($options['joinType']) ? $options['joinType'] : 'INNER');
$jta = 'active_other_invites';
if (!empty($options['joinTableAlias'])) {
$jta = $joinParams['alias'] = $options['joinTableAlias'];
}
$sugar_query->joinRaw($this->getCustomJoin($options), $joinParams);
return $sugar_query->join[$jta];
}
/**
* Builds main join subpanel
* @param string $params
* @return string JOIN clause
*/
protected function getCustomJoin($params = array())
{
$bean_id = $this->db->quoted($this->focus->id);
$sql = " INNER JOIN(";
$sql .= "SELECT id FROM accounts WHERE id={$bean_id}"; // This is essentially a select statement that will return a set of ids that you can match with the existing sugar_query
$sql .= ") accounts_result ON accounts_result.id = sugar_query_table.id";
return $sql;
}
<强>2。为链接字段添加一个新的 vardef 条目。
对于这个例子,我将在联系人模块上创建自定义链接。所以这段代码进入 custom/Extension/modules/Contacts/Ext/Vardefs/your_field_name.php
<?php
$dictionary["Contact"]["fields"]["your_field_name"] = array(
'name' => 'active_other_invites',
'type' => 'link',
'link_file' => 'custom/modules/<YourModule>/YourNewLink.php',
'link_class' => 'YourNewLink',
'source' => 'non-db',
'vname' => 'LBL_NEW_LINK',
'module' => '<YourModule>',
'link_type' => 'many',
'relationship' => '',
);
<强>3。将新链接添加为子面板
这在 custom/Extension/modules/Contacts/Ext/clients/base/layouts/subpanels/your_subpanel_name.php 下
<?php
$viewdefs['Contacts']['base']['layout']['subpanels']['components'][] = array (
'layout' => 'subpanel',
'label' => 'LBL_NEW_LINK',
'context' =>
array (
'link' => 'your_field_name',
),
);
<强>4。添加标签
在custom/Extension/modules/Contacts/Ext/Language/en_us.new_link.php下
<?php
$mod_strings['LBL_ACTIVE_OTHER_INVITES'] = 'Your New Link';
<强>5。快速修复和重建
关于sugarcrm - 如何将 "target lists"添加到我的自定义模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39077082/