Copied to clipboard

Flag this post as spam?

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


  • Topic author was deleted

    Oct 22, 2012 @ 16:59

    Iterate Through Document Properties

    I'm not sure if this is the best-practice, but was a hard to discover methodology for cycling through a documents properties.  Hope this speeds up development for someone in the future.

     
    MyDataType mydata = new MyDataType();

    doc = new Document(Convert.ToInt32(Request.QueryString["nodeID"]));
    //the node ID can be gotten by several methods, we were passing by query string

    foreach (umbraco.cms.businesslogic.property.Property prop in doc.GenericProperties)
    {
    //Do something

    //To work on a specific type of property type by GUID
    if (prop.PropertyType.DataTypeDefinition.DataType.Id == myData.Id)
    {

    }
    }

    Again there may be a better way, but the documentation I scrapped together on the Document Class and Property Class are not much help for specific class properties and methods.

    Visual Studio hinted that doc.GetProperties was deprecated, but didn't lead me to doc.GenericProperties explicitly.

    Stay classy Umbraco.

     

Please Sign in or register to post replies

Write your reply to:

Draft