【问题标题】:Pimcore Adding Button To Panel in Object EditorPimcore 在对象编辑器中将按钮添加到面板
【发布时间】:2020-03-01 00:40:44
【问题描述】:

我想在我自己的对象编辑器的面板中添加一个按钮。我成功地在对象编辑器中添加了一个图标和处理程序,就像示例文档中一样。 但是我想在编辑器下方的面板中的某处添加一个按钮。如何找出要扩展的 js 文件以便创建菜单按钮。

https://talk.pimcore.org/uploads/default/optimized/2X/7/725a347773479a7136600daeee66d7883ed19ae7_2_487x500.png

我试图扩展对象类,我想知道执行哪个函数来将我的按钮添加到此工具栏

`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();
    },
});`

你能在此处获取选项卡面板吗,或者我是否应该扩展对象类以便我可以在图像中添加按钮

【问题讨论】:

    标签: pimcore


    【解决方案1】:

    由于您没有发布完整的类定义,我只能估计 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() 调用。

    如果您更改类的布局,请务必调整代码,如果需要,如果您对每个布局使用custom layouts,请考虑调整上面的代码。

    你也可以看看Ext.js documentation for the Panel component,直接搜索被调用的方法就行了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-11
      • 1970-01-01
      • 2013-10-27
      • 1970-01-01
      • 1970-01-01
      • 2014-06-28
      • 1970-01-01
      • 2021-12-06
      相关资源
      最近更新 更多