有人可以告诉我如何从Cogworks灵活导航中排除文档类型吗?
如何允许从导航中排除文档类型的数组或列表?
注意:我不想使用"umbracoNaviHide",因为我希望排除文档类型,我不想在我的文档类型中添加一个真/假复选框,然后手动检查它们。
齿轮 - 灵活导航:http://our.umbraco.org/projects/website-utilities/cogworks-flexible-navigation
相关文章: Umbraco xslt 导航查询
这取决于您使用的是 Razor 版本还是 XSLT 版本。对于 XSLT,您需要向 XSLT 文件中节点迭代器模板上的"match"属性添加一个*[name()!='MyDoctypeAlias' or name()!='MyOtherDoctypeAlias']
。
对于 Razor 版本,在 nodeIterator 帮助程序中,我将定义如下:
List<string> listOfDoctypesToExclude = new List<string>() { "MyDoctypeAlias", "MyOtherDoctypeAlias" };
if (!listOfDoctypesToExclude.Contains(currentNode.NodeTypeAlias) {
// continue with render
}
我发现这作为捷径效果很好,但我仍然希望以某种方式创建排除文档类型的数组或列表。
首先隐藏祖先选定状态:
<!--Is the node a branch? i.e. are there children and is it in the colletion of ancestor nodes -->
<xsl:variable name="isBranch">
<xsl:choose>
<xsl:when test="$currentPage/ancestor-or-self::*[@isDoc][@id = $currentNodeID]/child::*[@isDoc][name() != 'MyDoctypeAlias']">1</xsl:when>
</xsl:choose>
</xsl:variable>
然后隐藏子节点(hasChildren):
<xsl:variable name="hasChildren">
<xsl:choose>
<xsl:when test="./*[@isDoc][name() != 'MyDoctypeAlias']">1</xsl:when>
</xsl:choose>
</xsl:variable>