为cq5组件添加动态路径域(rootPath)

VAr*_*VAr 1 aem

我们如何为cq5组件添加动态路径域(rootPath)?

有没有示例参考?

Tom*_*wek 10

我认为你应该使用自定义小部件插件.首先,添加属性pluginspathfielddialog.xml:

<myPathComponent
    jcr:primaryType="cq:Widget"
    fieldLabel="My path component"
    plugins="customRootPathPlugin"
    xtype="pathfield" />
Run Code Online (Sandbox Code Playgroud)

然后创建自定义ExtJS插件.为此,请创建新的JS文件,并将其添加到带有类别的clientlibcq.wcm.edit中.插件可能看起来像这样:

(function($) {
    var plugin = CQ.Ext.extend(CQ.Ext.emptyFn, {
        init: function(widget) {
            var locale = "en";

            // create some JS logic to get the locale here
            // current path can be obtained via
            // widget.findParentByType('dialog').responseScope.path
            widget.treeRoot.name = "content/myproject/" + locale + "/mycomponent";
        }
    });

    CQ.Ext.ComponentMgr.registerPlugin('customRootPathPlugin', plugin);
}($CQ));
Run Code Online (Sandbox Code Playgroud)