且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

一把umbraco 4.6+ - 如何获得由DOCTYPE在C#中的所有节点?

更新时间:2023-11-24 13:53:16

我只是在做这在今天,类似下面的code应该(用一把umbraco。presentation.nodeFactory)工作,用它打电话-1节点ID来获得该网站的根节点,让它工作,它是一路下滑:

I was just doing this today, something like the below code should work (using umbraco.presentation.nodeFactory), call it with a nodeId of -1 to get the root node of the site and let it work it's way down:

private void DoSomethingWithAllNodesByType(int NodeId, string typeName)
{
    var node = new Node(nodeId);
    foreach (Node childNode in node.Children)
    {
        var child = childNode;
        if (child.NodeTypeAlias == typeName)
        {
            //Do something
        }

        if (child.Children.Count > 0)
            GetAllNodesByType(child, typeName);
    }
}