Umbraco DynamicNodeWalker
我正在尝试找到一种优雅的方式来到达 umbracos DynamicNodeWalker 中的某个节点
这是图表:
Company
Division 1
Department
Team 1
Employee 1
Employee 2
Team 2
Department 2
Team 3
Employee 3
Employee 4
Team 4
Department 3
Department 4
Division 2
以下是如何使用 umbraco 文档
Assuming you're currently sitting on Company…
Model.Down().Next() //Division 2
Model.Down(1).Next().Down(1) //Employee 3
Or, if you're on Employee 3..
Model.Up(1).Previous().Down().Next() // Team 2
Model.Next() // Employee 4
如果您在员工 2 上 - 什么是进入 Team 2 的优雅方式吗?
I am trying to find an elegant way to get to a certain node in umbracos DynamicNodeWalker
Here is the diagram:
Company
Division 1
Department
Team 1
Employee 1
Employee 2
Team 2
Department 2
Team 3
Employee 3
Employee 4
Team 4
Department 3
Department 4
Division 2
Here is how to use the walker as stated in the umbraco documentation
Assuming you're currently sitting on Company…
Model.Down().Next() //Division 2
Model.Down(1).Next().Down(1) //Employee 3
Or, if you're on Employee 3..
Model.Up(1).Previous().Down().Next() // Team 2
Model.Next() // Employee 4
If you are on Employee 2 - what is an elegant way to get to Team 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
老实说,像这样遍历节点似乎本质上是不优雅的。随着树的结构融入到您的代码中。使用更通用的东西会更加灵活和可扩展。
然而,以下是如何遍历您正在寻找的节点的方法:
To be honest traversing nodes like this seems inherently inelegant. As the structure of the tree becomes baked into your code. Where using something more generic would be far more flexible and extensible.
However here's how to traverse for the node you are looking for: