【问题标题】:Modx hide content field from a specific tabModx 从特定选项卡中隐藏内容字段
【发布时间】:2015-10-12 10:55:45
【问题描述】:

Modx revo 最新版本

我需要从使用表单自定义创建的特定选项卡中隐藏内容字段,我找到了这个 Ext JS 代码,但我不知道如何实现它。它是一个插件 ondocformrender 吗?我应该创建一个js文件吗?

Ext.onReady(function(){
var tabPanel = Ext.getCmp("modx-resource-tabs");

if(tabPanel!=null){
    //Add my custom tab
    var customTab = {
        title: 'Custom',
        id: 'my-custom-tab',
        cls: 'modx-resource-tab',
        layout: 'fit',
        labelAlign: 'top',
        labelSeparator: '',
        bodyCssClass: 'tab-panel-wrapper main-wrapper',
        autoHeight: true,
        defaults: {
            border: false,
            msgTarget: 'under',
            width: 400,
            height:800
        },
        items: [
            {
                xtype: "box",
                autoEl: {cn: '<div id="target_id"></div>'}
            }
        ]
    };
    tabPanel.on('tabchange', function(parent,selectedTab){ 
        if (selectedTab.id == 'my-custom-tab') {
            Ext.getCmp("modx-resource-content").hide();
        }
        else {
            Ext.getCmp("modx-resource-content").show();
        }
    });
    tabPanel.insert(0, customTab);
    tabPanel.setActiveTab(0);
    tabPanel.doLayout();
}
});

【问题讨论】:

    标签: javascript extjs modx modx-revolution


    【解决方案1】:

    你不需要编辑任何 ExtJS,你可以通过 MODX 的Manager Customization 功能来完成。

    请参阅随附的屏幕截图以供参考。

    【讨论】:

    • 它将完全删除内容字段,但我需要它仅显示在文档选项卡下。
    【解决方案2】:

    我在 OnDocFormPrerender 上做了一个这样的插件:

    <?php
    switch ($modx->event->name) {
    // Add a custom tab to the MODX create/edit resource pages
    case 'OnDocFormPrerender':
        $custom_html = 'Your custom HTML, e.g. from a model function or API         lookup etc.';
        $modx->regClientStartupHTMLBlock('<script type="text/javascript">
            Ext.onReady(function(){
    var tabPanel = Ext.getCmp("modx-resource-tabs");
    
    if(tabPanel!=null){
        tabPanel.on(\'tabchange\', function(parent,selectedTab){ 
            if (selectedTab.id == \'modx-ref\') {
                Ext.getCmp("modx-resource-content").hide();
            }
            else {
                Ext.getCmp("modx-resource-content").show();
            }
        });
        tabPanel.insert(0, customTab);
        tabPanel.setActiveTab(0);
        tabPanel.doLayout();
    }
    });               
        </script>');
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-11
      • 2020-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-17
      相关资源
      最近更新 更多