Just a thought, how about adding a label property to the master doctype and then checking for it's exitance ? (for example I ofen add a 'isSitePage' property to a base SitePage docType which makes the XPath really simple to get all site pages, or to use the .HasProperty("isSitePage"))
Yes you’re right that would have been a much simpler solution with less cycles! I was thinking too much in terms of the umbraco node hierarchy schema.
Does nodes document type inherit from method
Is there a method on a DynamicNode in umbraco already to check if the nodes document type inherits from a cirtain document type either by alias or id.
Or has anyone made an extention method on DynamicNode to make something like:
bool InheritsFromMyDocType = ((DynamicNode)page).DocTypeInheritsFrom("DocTypeAlias");
I need it to loop through a number of child pages and only take the ones that inherit from a base document type.
Figured out something that seems to work
//umbraco.MacroEngines.DynamicNode
public static bool IsNodeDocTypeInheritFrom(this DynamicNode node, string documentTypeAlias)
{
DocumentType current = DocumentType.GetByAlias(node.NodeTypeAlias);
while (current.Alias != documentTypeAlias)
{
if (current.MasterContentType == -1)
{
return false;
}
current = new DocumentType(current.MasterContentType);
}
return true;
}
Hi Mark,
Just a thought, how about adding a label property to the master doctype and then checking for it's exitance ? (for example I ofen add a 'isSitePage' property to a base SitePage docType which makes the XPath really simple to get all site pages, or to use the .HasProperty("isSitePage"))
Hendy
Yes you’re right that would have been a much simpler solution with less cycles! I was thinking too much in terms of the umbraco node hierarchy schema.
is working on a reply...