Copied to clipboard

Flag this post as spam?

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


  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 25, 2010 @ 14:23
    Jeroen Breuer
    0

    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

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 25, 2010 @ 15:40
    Lee Kelleher
    0

    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?

    new umbraco.cms.businesslogic.web.Document(int.Parse(HttpContext.Current.Request.QueryString["id"])).ContentType.Alias;

    Since the "id" querystring is used for the editContent page.

    Good luck, Lee.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 25, 2010 @ 15:51
    Jeroen Breuer
    0

    Hi Lee,

    That should probably work. Thanks!

    Jeroen

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 25, 2010 @ 15:59
    Lee Kelleher
    0

    I was tempted to use "umbraco.presentation.nodeFactory.Node" - but that would only work on content that is already published!

  • Edward Dudley 80 posts 121 karma points
    Feb 25, 2010 @ 23:48
    Edward Dudley
    0

    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:

    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!

    I just used the SQLHelper to execute this.

     

  • Edward Dudley 80 posts 121 karma points
    Feb 26, 2010 @ 10:27
    Edward Dudley
    0

    OK, just in case you're interested in going the SQL route, the query would be:

    SELECT [nodeId]
    ,[alias]
    FROM [cmsContentType]
    where [nodeId] = (SELECT [contentType] FROM [cmsContent] where nodeId = 1234)

    Where 1234 is the node ID that you pull from the request collection.

    Hope that helps!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 26, 2010 @ 10:39
    Jeroen Breuer
    0

    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;
  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 26, 2010 @ 12:44
    Lee Kelleher
    0

    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.

    ((umbraco.uicontrols.PropertyPanel)this.Parent.Parent).Text

    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.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Dec 29, 2010 @ 01:25
    Lee Kelleher
    1

    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!

    this.DataEditor.Editor.ID

    Cheers, Lee.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Dec 29, 2010 @ 08:35
    Jeroen Breuer
    1

    Hi Lee,

    I've also figured out another way to get the property id and alias I think. This should also work:

    ((DefaultData)this.Data).PropertyId

    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

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Dec 30, 2010 @ 09:10
    Lee Kelleher
    0

    Nice one Jeroen... I did not know that!

    Thanks, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft