2014-10-27 78 views
2

使用rference paragraph component我可以通过浏览其路径来显示其他段落系统的内容。如何隐藏reference paragraph的某个content/paths?以附图为例,如何隐藏Productsenter image description here如何隐藏参考段落组件中的路径

回答

2

我希望我的回答是相关的。 所以要做到这一点,你需要:

  1. 创建谓词筛选页面显示在对话框中。
  2. 创建自己的选择页面控件(立足于默认的)
  3. 创建自己的基准件(立足于默认的)

所以你的判断可以是这样的:

import com.day.cq.commons.predicate.AbstractNodePredicate; 
import org.apache.commons.collections.Predicate; 
import org.apache.felix.scr.annotations.Component; 
import org.apache.felix.scr.annotations.Property; 
import org.apache.felix.scr.annotations.Service; 
import javax.jcr.Node; 
import javax.jcr.RepositoryException; 

@Component 
@Service 
@Property(name = "predicate.name", value = "myPredicate") 
public class MyPredicate extends AbstractNodePredicate implements Predicate { 

    @Override 
    public boolean evaluate(final Node node) throws RepositoryException { 
     return node.isNodeType("nt:hierarchyNode") 
      && !node.getPath().startsWith("/content/geometrixx/en/products"); 
    } 
} 

return node.isNodeType("nt:hierarchyNode")取自CQ提供的另一个谓词IsHierarchyNodePredicate。我们添加了另一个声明 - 按路径过滤。

然后我们需要创建我们自己的小部件,我们将使用我们的谓词。从ParagraphReference

  1. 重命名部件(CQ.form:要做到这一点,复制“/libs/cq/ui/widgets/source/widgets/form/ParagraphReference.js”到项目中,编辑完它在接下来的方式.ParagraphReference)到MyParagraphReference(CQ.form.MyParagraphReference)并将其注册为新的xtype - myparagraphreference。
  2. 将其添加到cq.widgets类别中,因此它将在作者模式下可用。
  3. 在这个文件中,你会发现下一个行:

    var loader = new CQ.Ext.tree.TreeLoader({ 
        "url":   CQ.HTTP.externalize("/content.ext.json"), 
        "requestMethod": "GET", 
        "baseParams": { "predicate": "hierarchy", "depth": 0 }, 
        "baseAttrs":  { "iconCls": "page" } 
    }); 
    
  4. 变化"predicate": "hierarchy""predicate": "myPredicate"

下一步将是我们的组件。将“/ libs/foundation/components/reference”组件复制到您的项目并编辑它的对话框 - 将参考节点的xtype更改为“myparagraphreference”。

所以从这一刻起,您可以在伙伴中找到您的组件,并且不会有节点“产品”。

enter image description here

P.S:您也可以只覆盖默认组件与一个和覆盖默认小部件,而不是创造新的。

如果您有任何问题 - 请不要犹豫,问我。 祝你好运。

修订

+0

这工作得很好谢谢:) – Ronald 2014-11-04 06:42:31