there may be a quicker way to get the node type id but you can use the GetXmlNodeCurrent() from the umbraco.library and then pull the node type id out of there. the name of the property is "nodeType" and the value will be the ID.
After a bit of exploring I found that the node id is in the request collection (Request.QueryString["id"]).
The following SQL can then be executed to give a list of allowed templates for a given content node id (1044 in the example below):
SELECT [nodeId] ,[alias] FROM [cmsTemplate] where [nodeId] in ( SELECT [templateNodeId] FROM [EdMobTest].[dbo].[cmsDocumentType] where [contentTypeNodeId] = (SELECT [contentType] FROM [cmsContent] where nodeId = 1044))
Or, alternatively, if you wanted the template name instead of the alias:
SELECT [id] ,[text] FROM [umbracoNode] where [id] in ( SELECT [templateNodeId] FROM [EdMobTest].[dbo].[cmsDocumentType] where [contentTypeNodeId] = (SELECT [contentType] FROM [cmsContent] where nodeId = 1044))
Data Type DocType ID
I'm following the excellent tutorial at:
http://www.nibble.be/?p=24
But I'd like to pull values from the database depending on the doc type. Is there an easy way to get hold of the DocType ID?
Or is there some way to get the ID of the node currently being edited so that I could query the DB?
Thanks!
Hover over the node and look at the left bottom.
Cheers,
/Dirk
Thanks Dirk, but I think you misunderstood what I meant!
I'd like to programatically determine the doc type ID from a custom data type....
So the when the custom data type appears on an editing page it customises itself depending on the doc type.
Sorry if I was unclear!
there may be a quicker way to get the node type id but you can use the GetXmlNodeCurrent() from the umbraco.library and then pull the node type id out of there. the name of the property is "nodeType" and the value will be the ID.
and that will work in a custom data type?
Excuse my ignorance, I've only recently started extending umbraco!
Cast your Data object in the datatype to DefaultData. It will provide you the nodeId
Thanks for the help guys.
After a bit of exploring I found that the node id is in the request collection (Request.QueryString["id"]).
The following SQL can then be executed to give a list of allowed templates for a given content node id (1044 in the example below):
Hope this helps someone else out too.
Or, alternatively, if you wanted the template name instead of the alias:
is working on a reply...