I've recently done something like this - I'm pretty sure that the node ID is in the request collection (Request.QueryString["id"]).
Once you've got the node ID you can get the document type ID with:
SELECT [contentType] FROM [cmsContent]where nodeId = 1234
(I think - check this and if it's wrong I'll dig into my code again).
I've not got access to my database to check the schema at the moment, but I'm pretty sure you'll be able to find where the alias is stored and it should be easy enough to write a query to pull it out given the doc type id. I'll check back tomorrow when I can look at the DB!
Thanks for this Edward! Actually I made a mistake in asking my question. I don't need the alias of the document type, but the name of a property of the datatype. I need this name inside my custom datatype. So all I really need is the alias of the datatype inside my custom datatype. Is this possible?
Your code can also be done the following way:
Document document = new Document(HttpContext.Current.Request.QueryString["id"]);
string alias = document.ContentType.Alias;
Document type alias in custom datatype
Hello,
I've got a custom datatype in which I would like to know the alias from the document type. Can I get this data?
Jeroen
Hi Jeroen,
I don't know of a direct way of accessing the doc-type alias from a custom data-type, but you could try an indirect approach?
Since the "id" querystring is used for the editContent page.
Good luck, Lee.
Hi Lee,
That should probably work. Thanks!
Jeroen
I was tempted to use "umbraco.presentation.nodeFactory.Node" - but that would only work on content that is already published!
Hi,
I've recently done something like this - I'm pretty sure that the node ID is in the request collection (Request.QueryString["id"]).
Once you've got the node ID you can get the document type ID with:
(I think - check this and if it's wrong I'll dig into my code again).
I've not got access to my database to check the schema at the moment, but I'm pretty sure you'll be able to find where the alias is stored and it should be easy enough to write a query to pull it out given the doc type id. I'll check back tomorrow when I can look at the DB!
I just used the SQLHelper to execute this.
OK, just in case you're interested in going the SQL route, the query would be:
Where 1234 is the node ID that you pull from the request collection.
Hope that helps!
Thanks for this Edward! Actually I made a mistake in asking my question. I don't need the alias of the document type, but the name of a property of the datatype. I need this name inside my custom datatype. So all I really need is the alias of the datatype inside my custom datatype. Is this possible?
Your code can also be done the following way:
Hi Jeroen,
OK, you got me curious on how to get the property name (alias) for the data-type (that is used in a document-type)!! Here's how I'd do it.
I couldn't find a way using the Umbraco API to access the property name. So I thought navigating up the Control tree would be much easier.
I'm not sure what type of controls you are using in your custom data-type ... but you may need to test which ".Parent" the PropertyPanel is.
Good luck, Lee.
Stumbled across this old topic via a Google search - trying to figure out how to get the Property Alias from within the data-type code.
I found that the property-alias is stored in the ID of the DataEditor's Editor control!
Cheers, Lee.
Hi Lee,
I've also figured out another way to get the property id and alias I think. This should also work:
If you want to see a sample in which I get all the data of a PropertyType (including the alias) see the last post of the following page: http://our.umbraco.org/forum/developers/extending-umbraco/14157-Make-custom-datatype-mandatory?p=1
Jeroen
Nice one Jeroen... I did not know that!
Thanks, Lee.
is working on a reply...