pimcore - Pimcore 在对象编辑器中将按钮添加到面板
问题描述
我想在我自己的对象编辑器的面板中添加一个按钮。我成功地在对象编辑器中添加了一个图标和处理程序,就像示例文档中一样。但是我想在编辑器下方的面板中的某处添加一个按钮。如何找出要扩展的 js 文件,以便创建菜单按钮。
我试图扩展对象类,我想知道执行哪个函数来将我的按钮添加到这个工具栏
`pimcore.plugin.celumImage = Class.create(pimcore.plugin.admin, {
postOpenObject: function (object, type) {
console.log("dsdsd"+object.data.general.o_className);
object.toolbar.add({
text: t('show-pdf'),
iconCls: 'pimcore_icon_pdf',
scale: 'small',
handler: function (obj) {
//do some stuff here, e.g. open a new window with an PDF download
}.bind(this, object)
});
pimcore.layout.refresh();
},
});`
你能在这里得到标签面板还是我应该扩展对象类以便我可以在图像中添加按钮
解决方案
由于您没有发布完整的类定义,我只能估计 javascript 应该是什么样子。如果您只有一个简单的 tabpabel,则可以使用以下内容:
postOpenObject: function (object, type) {
object.tabPanel
.getComponent(0) // get object tab
.getComponent(1) // get edit tabpanel
.getComponent(0) // get class tab
.getComponent(3) // get fourth tab in class tabpanel
.query("*[componentCls~=object_field]")[0] // get first panel with class "object_field" - could be replaced with down(...)
.getDockedComponent(0) // get toolbar
.add({
text: t('show-pdf'),
iconCls: 'pimcore_icon_pdf',
scale: 'small',
handler: function (obj) {
//do some stuff here, e.g. open a new window with an PDF download
}.bind(this, object)
});
})
根据数据对象的布局有多复杂(或将有多复杂),您可以删除getComponent()
调用并直接down()
调用对象标签。
如果您更改类的布局,请确保调整代码,如果需要,如果您为每个布局使用自定义布局,请考虑调整上面的代码。
您也可以查看Panel 组件的 Ext.js 文档,只需搜索被调用的方法。
推荐阅读
- javascript - 试图在 GoogleScript 中重现 Excel“LEFT()”函数
- node.js - 测试路由并在其中存根函数调用?
- javascript - react-transition-group 动画的布局中断
- datetime - 如何在本机反应中将 linux 时间戳转换为波斯语/jalali?
- python - 在 Windows 模型中为 Odoo 开发配置 PyCharm 未找到
- bash - 在字符串模式之间插入反引号
- lucene - 使用 GraphDB 的 Lucene 连接器时,如何不通过 SPARQL 直接访问 Lucene?
- angular - AWS EC2 实例正在运行,但我无法连接
- javascript - 定义所有属性时无法读取未定义 React 的属性“绑定”
- knockout.js - 为什么在表行中使用 data-bind ='if' 时会出现 Knockout js 的 ReferenceError