Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeff Chapin 18 posts 39 karma points
    Jul 25, 2011 @ 22:22
    Jeff Chapin
    0

    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.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 26, 2011 @ 07:46
    Dirk De Grave
    0

    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>

  • Jeff Chapin 18 posts 39 karma points
    Jul 27, 2011 @ 04:02
    Jeff Chapin
    0

    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. 

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 27, 2011 @ 08:51
    Dirk De Grave
    0

    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

     

Please Sign in or register to post replies

Write your reply to:

Draft