Copied to clipboard

Flag this post as spam?

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


  • Edward Dudley 80 posts 121 karma points
    Jan 18, 2010 @ 15:36
    Edward Dudley
    0

    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!

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 18, 2010 @ 16:21
    Dirk De Grave
    0

    Hover over the node and look at the left bottom.

     

    Cheers,

    /Dirk

  • Edward Dudley 80 posts 121 karma points
    Jan 18, 2010 @ 17:09
    Edward Dudley
    0

    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!

     

  • Seth Niemuth 275 posts 397 karma points
    Jan 18, 2010 @ 17:32
    Seth Niemuth
    0

    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.

  • Edward Dudley 80 posts 121 karma points
    Jan 18, 2010 @ 18:37
    Edward Dudley
    0

    and that will work in a custom data type?

    Excuse my ignorance, I've only recently started extending umbraco!

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Jan 19, 2010 @ 09:32
    Casey Neehouse
    0

    Cast your Data object in the datatype to DefaultData.  It will provide you the nodeId

  • Edward Dudley 80 posts 121 karma points
    Jan 19, 2010 @ 10:25
    Edward Dudley
    0

    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):

    SELECT [nodeId]
    ,[alias]
    FROM [cmsTemplate]
    where [nodeId] in (
    SELECT [templateNodeId]
    FROM [EdMobTest].[dbo].[cmsDocumentType]
    where [contentTypeNodeId] = (SELECT [contentType] FROM [cmsContent] where nodeId = 1044))

    Hope this helps someone else out too.

  • Edward Dudley 80 posts 121 karma points
    Jan 19, 2010 @ 10:44
    Edward Dudley
    0

    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))
Please Sign in or register to post replies

Write your reply to:

Draft