为cq5组件添加动态pathfield(rootPath) [英] Add dynamic pathfield(rootPath) for cq5 component
本文介绍了为cq5组件添加动态pathfield(rootPath)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何为cq5组件添加动态pathfield(rootPath)?
How can we add a dynamic pathfield(rootPath) for a cq5 component?
是否有示例引用?
推荐答案
我认为您应该使用自定义小部件插件。首先,在 dialog.xml $ c $中将属性
plugins
添加到 pathfield
c>:
I think you should use custom widget plugin. First, add property plugins
to your pathfield
in the dialog.xml
:
<myPathComponent
jcr:primaryType="cq:Widget"
fieldLabel="My path component"
plugins="customRootPathPlugin"
xtype="pathfield" />
然后创建自定义ExtJS插件。为此,请创建新的JS文件,并将其添加到 clientlib 和 cq.wcm.edit
类别。插件看起来像这样:
Then create custom ExtJS plugin. In order to do that, create new JS file, and add it to clientlib with cq.wcm.edit
category. Plugin can look like that:
(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));
这篇关于为cq5组件添加动态pathfield(rootPath)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文