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
How can i tell what type of object is represented for a specified ID?
Basically given an ID like 1045 i want to be able to determine if this is a Member, MemberGroup, Document, etc...
If nothing else, i'd just like to confirm that the specified ID is the ID of an existing MemberGroup.
Best solution I'm aware of for this is to look after the nodeObjectType property on your node object (returns a guid) and compare it with existing guid for the different node types (content, media, stylesheet, ...)
public static Guid _objectType = new Guid("b796f64c-1f99-4ffb-b886-4bf4bc011a9c"); // static Guid on the Media class
and compare this with the myNode.nodeObjectType (which is also a guid). If both are equal, then node myNode is of that type.
Hope this helps.
How do i know what Guid is for a given type? Is this stored in a table?
As that guid is a static field on the type! As in example above, the guid is for the MediaType (such as the File, Folder and Image from the media section)
A node mediaNode is of type Media if
mediaNode._objectType.ToString() == new Guid("").ToString();
Does that clarify things?
Thanks for your help. I wrote this case statement to determine the object type:
public static System.Type GetNodeType(int nodeId)
System.Type t = null;
CMSNode n = new CMSNode(nodeId);
t = typeof(umbraco.cms.businesslogic.web.DocumentType);
t = typeof(umbraco.cms.businesslogic.web.Document);
t = typeof(umbraco.cms.businesslogic.member.MemberType);
t = typeof(umbraco.cms.businesslogic.template.Template);
t = typeof(umbraco.cms.businesslogic.member.MemberGroup);
t = typeof(umbraco.cms.businesslogic.web.StyleSheet);
t = typeof(umbraco.cms.businesslogic.member.Member);
t = typeof(umbraco.cms.businesslogic.media.MediaType);
t = typeof(umbraco.cms.businesslogic.media.Media);
t = typeof(umbraco.cms.businesslogic.RecycleBin);
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted