如何为cq5组件添加动态路径字段(RootPath)?
有没有什么示例参考?
发布于 2013-09-27 16:52:47
我认为你应该使用自定义的小部件插件。首先,将属性plugins添加到dialog.xml中的pathfield中
<myPathComponent
jcr:primaryType="cq:Widget"
fieldLabel="My path component"
plugins="customRootPathPlugin"
xtype="pathfield" />然后创建自定义ExtJS插件。为此,请创建新的JS文件,并将其添加到带有cq.wcm.edit的clientlib类别中。插件可以看起来像这样:
(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));发布于 2014-10-14 01:39:43
为了扩展Tomek的答案,我能够获得当前页面,然后显示所有兄弟姐妹和子页面,如下所示:
(function($) {
var plugin = CQ.Ext.extend(CQ.Ext.emptyFn, {
init : function(widget) {
var url = CQ.HTTP.getPath();
widget.treeRoot.name = url.substring(1, url.lastIndexOf('/') );
}
});
CQ.Ext.ComponentMgr.registerPlugin('customRootPathPlugin', plugin);}($CQ));我使用url.substring(1而不是url.substring(0的原因是因为我会在对话框中看到双正斜杠//content/app/en/。
https://stackoverflow.com/questions/19029410
复制相似问题