[英]Where to Include Sugarcrm
我一直在为Sugar模块编写一些自定义代码,还不清楚将我的JavaScript代码放在哪里。
目前,我已将我的自定义JS放在include / javascript / popup_parent_helper.js中
这在开发人员模式下工作正常,但在关闭该功能后却无法正常工作,不幸的是,dveloper模式运行速度超级慢
我做了很多研究,但结果却有些矛盾。
有人告诉我,我应该将其包括在:
其他人则说应该在:
请帮助我阐明适当的结构以及需要在其中做出适当的包含声明的地方
说明:
我们正在使用SugarCrm 6.5x
在这种情况下,JS仅用于一个模块。
在快速创建视图和编辑视图中使用它
如果任何模块都可以访问JavaScript,则可以使用以下技术创建新的JSGrouping并提取自定义js文件: http : //support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/Extension_Framework/JSGroupings/ #Creating_New_JSGroupings
听起来您希望将其隔离到自定义模块中,因此您可能应该扩展所需的视图。 如果要扩展记录视图,请在custom / modules / -your_module- / clients / base / views / record /下创建一个名为record.js的新文件。
({
extendsFrom: 'RecordView',
initialize: function(options) {
this._super('initialize', [options]);
this.doSomething();
},
doSomething: function(){
console.log("Help you I will");
},
...
})
https://developer.sugarcrm.com/2014/02/10/extending-sugar-7-record-view/
我也遇到过类似的问题(JS应该可以用于编辑和快速创建表单),但是在进行一些RnD之后,我按照以下方式实现了它:
\custom\modules\<modulename>\views\view.edit.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/MVC/View/views/view.edit.php');
class {moduleName}ViewEdit extends ViewEdit {
public function __construct() {
parent::ViewEdit();
$this->useForSubpanel = true; // this variable specifies that these changes should work for subpanel
// / $this->useModuleQuickCreateTemplate = true; // quick create template too
}
function display(){ ?>
<?php
$jsscript = <<<EOQ
<script>
Your JS code
</script>
EOQ;
parent::display();
echo $jsscript; //echo the script
}
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.