Created
July 30, 2013 16:25
-
-
Save csharpforevermore/6114503 to your computer and use it in GitHub Desktop.
If you want to find the ID of the first node with a specific Document Type, use this code by supplying the document type alias here (i.e. the method signature property "docTypeAlias").
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int GetFirstNodeWithDocumentAlias(string docTypeAlias) | |
{ | |
int locationsPageId = -1; | |
DynamicNode searchPage = null; | |
var nodes = new DynamicNode(-1).Descendants(); | |
foreach (DynamicNode node in nodes){ | |
if (node.NodeTypeAlias.ToLower().StartsWith(docTypeAlias.ToLower())) | |
{ | |
searchPage = node; break; | |
} | |
} | |
if(searchPage != null) { | |
locationsPageId = searchPage.Id; | |
} | |
return locationsPageId; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment