当前页面是特定节点 id 的后代吗? [英] Is the current page a descendant of a specific node id?

查看:44
本文介绍了当前页面是特定节点 id 的后代吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Umbraco 中使用 razor 模板进行检查以确定当前页面是否是特定节点的后代?我将使用 case 语句.

How do I check using a razor template in Umbraco to determine if the current page is a descendant of a specific node? I'll be using a case statement.

推荐答案

不确定这些方法是否仍然适用于最新版本的 Umbraco,但在 4.7.1 和 DynamicNode 中曾经有那些方法:

Not sure if those methods still work with the latest version of Umbraco, but with 4.7.1 and DynamicNode there use to be those methods:

@Model.AncestorOrSelf(string nodeTypeAlias)
@Model.AncestorOrSelf(int level)
@Model.AncestorOrSelf(Func<DynamicNode, bool> func)

和那些辅助函数:

@Model.IsDescendant(DynamicNode[,valueIfTrue][,valueIfFalse])
@Model.IsDescendantOrSelf(DynamicNode[,valueIfTrue][,valueIfFalse])

这篇关于当前页面是特定节点 id 的后代吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆