2014-10-27 80 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