Copied to clipboard

Flag this post as spam?

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


  • Ove Andersen 435 posts 1541 karma points c-trib
    Aug 27, 2010 @ 10:00
    Ove Andersen
    0

    Get PropertyType of a Node Property

    I need to get the PropertyType of a Property in my usercontrol.

    The Property is specified by using the propertyTypePicker macro control, so I have the Alias.

    I knwo I can get the ID by using PropertyType.GetPropertyType(), but then I need the ID, not the Alias.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 27, 2010 @ 10:07
    Aaron Powell
    1

    The Umbraco XML doesn't store the information about the property type, you have to map it back to the actual Document object

  • Ove Andersen 435 posts 1541 karma points c-trib
    Aug 27, 2010 @ 13:04
    Ove Andersen
    0

    Thanks! That got me on the right track.

    Solved it by doing the following:

    Document d = new Document(Node.GetCurrent().Id);



    // Get Property Alias from Macro
    PropertyType pt = d.getProperty(this.PropertyAlias).PropertyType;


    // Get Prevalues
    SortedList prevalues = PreValues.GetPreValues(pt.DataTypeDefinition.Id);
  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 28, 2010 @ 00:32
    Aaron Powell
    0

    You don't want to be running that code too often, I think that does 3  database calls to get what you need and that's just unavoidable from the current Umbraco design.

  • Ove Andersen 435 posts 1541 karma points c-trib
    Aug 28, 2010 @ 14:11
    Ove Andersen
    0

    It could be solved by entering the datatype id as a macro parameter.

    Then I can get the prevalues without going the heavy way.

    If you come up with a better suggestion, don't hestitate to tell me =)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies