有人可以告诉我如何从 Cogworks 灵活导航中排除文档类型吗?
如何允许从导航中排除文档类型的数组或列表?
注意:我不想使用“umbracoNaviHide”,因为我想排除文档类型,我不想在我的文档类型中添加一个真/假复选框,然后手动检查它们。
Cogworks - 灵活导航:http ://our.umbraco.org/projects/website-utilities/cogworks-flexible-navigation
相关文章:Umbraco xslt 导航查询
有人可以告诉我如何从 Cogworks 灵活导航中排除文档类型吗?
如何允许从导航中排除文档类型的数组或列表?
注意:我不想使用“umbracoNaviHide”,因为我想排除文档类型,我不想在我的文档类型中添加一个真/假复选框,然后手动检查它们。
Cogworks - 灵活导航:http ://our.umbraco.org/projects/website-utilities/cogworks-flexible-navigation
相关文章:Umbraco xslt 导航查询
这取决于您使用的是 Razor 版本还是 XSLT 版本。对于 XSLT,您将*[name()!='MyDoctypeAlias' or name()!='MyOtherDoctypeAlias']
在 XSLT 文件中的 nodeIterator 模板的“match”属性中添加一个。
对于 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>