Copied to clipboard

Flag this post as spam?

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


  • msegers 2 posts 20 karma points
    Mar 19, 2009 @ 14:40
    msegers
    0

    enumerating Data Types from xslt extension

    Hi there,

    Does anyone know how to enumerate the available data Types
    from within a custom xslt extension?

    I am writing an XSLT extension that has to format content depending on
    a specific prevalue setting I configured in a specific data type.

    Therefore I need to enumerate all Data Types, find the correct one,
    read the prevalue settings and format my content.

    I can not find a way to enumerate these Data Types.

    I do hope I don't have to make a direct Database connection
    and load it from the cmsDataType and cmsDataTypePreValues tables.

    anyone?

  • msegers 2 posts 20 karma points
    Mar 19, 2009 @ 16:12
    msegers
    0

    FOUND IT!

    I created a function that will retrieve the interface to
    the datatype using the DataTypeName as created in
    Development > Data Types

    [code]
    ...
    using umbraco.interfaces;
    using umbraco.cms.businesslogic;
    using umbraco.cms.businesslogic.web;
    using umbraco.cms.businesslogic.datatype;
    ...

    // retrieve a data type interface using its data type name
    static public IDataType GetDataTypeByDataTypeName(string DataTypeName)
    {
    // get all data type definitions
    DataTypeDefinition[] dfa = DataTypeDefinition.GetAll();

    // iterate through all data type definitions
    for (int di = 0; di < dfa.Length; di++)
    {
    // get data type interface of data type definition
    IDataType datatype = dfa[di].DataType;
    // get cms node belonging to this data type
    // for name compare purposes
    CMSNode node = new CMSNode(datatype.DataTypeDefinitionId);
    // compare data type name - case insensitive
    if (node.Text.ToLower() == DataTypeName.ToLower())
    {
    // data type was found
    return datatype;
    }
    }
    // data type was not found
    return null;
    }

    [/code]

  • 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