If I've tcmUri say(tcm:31-2-1) how can I know the nature of it. Whether it is Component,Page,Schema,Folder etc. Do we have anything in core services by which we can check>
2 Answers
I always use this TcmUri class: https://gist.github.com/quirijnslings/d9ff8a421f9087b4b24f8b8942de6675.
You can use it like this:
var uri = new TcmUri("tcm:0-23-1");
var itemType = uri.ItemTypeId;
-
1
You can just look at it and see.
Tcm Uri is constructed of publication id, item id, and item type. In your case:
- 0 is the publication id where your item is.
- 23 is the item id
- 1 is item type which is publication type.
So, you can just get that last number and find it in the core service ItemType
enum:
Also, make note that components are specific, meaning that they don't need to have 16 added, so you need to check that one also. My case, just split that string into sections. Check for the last section that is item type and compare