开发者

Umbraco DynamicNodeWalker

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?


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:

Model.Up().Next();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜