Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save csharpforevermore/6114503 to your computer and use it in GitHub Desktop.
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").
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