Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
In C# how do I query for, or list, the allowed child nodetypes.
The Umbraco editor list the 'allowed child node types' under the Structure tab. I want to get that info in a user control.
Hi Jeff,
Just use this code snippet:
ContentType ct = new ContentType(id); // or use ContentType ct = ContentType.GetByAlias(alias);int[] allowedContentTypes = ct.AllowedContentTypeIDs;foreach (int act in allowedContentTypes) { ContentType allowedContentType = new ContentType(act); }
Hope this helps.
Regards,
/Dirk>
Thanks!!! - Dirk that worked.
Just one more thing... your code gets me the ID's of the allowed node types but is there a way to get the alias name of the allowed nodes?
If not, you gave me enough to get me working - thanks.
Oh yeah, sure it can be done, you're so close...
ContentType ct =newContentType(id);// or use ContentType ct = ContentType.GetByAlias(alias);int[] allowedContentTypes = ct.AllowedContentTypeIDs;foreach(int act in allowedContentTypes){ ContentType allowedContentType =newContentType(act); string alias = allowedContentType.Alias;}
Cheers,
/Dirk
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
List allowed child nodetypes
In C# how do I query for, or list, the allowed child nodetypes.
The Umbraco editor list the 'allowed child node types' under the Structure tab. I want to get that info in a user control.
Hi Jeff,
Just use this code snippet:
Hope this helps.
Regards,
/Dirk>
Thanks!!! - Dirk that worked.
Just one more thing... your code gets me the ID's of the allowed node types but is there a way to get the alias name of the allowed nodes?
If not, you gave me enough to get me working - thanks.
Oh yeah, sure it can be done, you're so close...
ContentType ct =newContentType(id);// or use ContentType ct = ContentType.GetByAlias(alias);
int[] allowedContentTypes = ct.AllowedContentTypeIDs;
foreach(int act in allowedContentTypes){
ContentType allowedContentType =newContentType(act);
string alias = allowedContentType.Alias;
}
Cheers,
/Dirk
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.