Copied to clipboard

Flag this post as spam?

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


  • MarcC 49 posts 356 karma points
    Nov 29, 2018 @ 16:09
    MarcC
    0

    Is there is a way to link up the data types used in a doctypes properties.

    Hey,

    I am creating a small tool to help identify site usage stats from a content editors point of view.

    My current challenge is using the available services I cannot see how to match a content nodes properties with a specific data type.

    Example of ContentService output from the home node's property values.

     {
    "$id": "5",
    "Alias": "SiteLogo",
    "Version": "8607ce10-212d-48bd-b1c9-5f348ed3892a",
    "Value": null,
    "Id": 270,
    "Key": "f9e11f36-4b54-4292-94ac-e44d167fbbb8",
    "CreateDate": "2018-11-27T12:06:51.54Z",
    "UpdateDate": "2018-11-27T12:07:37.51Z",
    "HasIdentity": true
    }
    

    Key, version and Id dont seem to match up with anything available on the DataType service output

    {
    "$id": "22",
    "ParentId": -1,
    "Name": "Media Picker",
    "SortOrder": 2,
    "Level": 1,
    "Path": "-1,1048",
    "CreatorId": 0,
    "Trashed": false,
    "PropertyEditorAlias": "Umbraco.MediaPicker2",
    "ControlId": "556d6272-6163-6f2e-4d65-646961506963",
    "DatabaseType": 0,
    "Id": 1048,
    "Key": "135d60e0-64d9-49ed-ab08-893c9ba44ae5",
    "CreateDate": "2018-11-21T15:57:10.957Z",
    "UpdateDate": "2018-11-21T15:57:10.957Z",
    "HasIdentity": true
    }...
    

    Curious if there is a way to go about linking up the data types used in a doctypes properties.

    Cheers,

    M

  • MarcC 49 posts 356 karma points
    Dec 03, 2018 @ 09:20
    MarcC
    0

    I wasn't able to find a solution so I created a custom view to tie up both and I query this using dapper. If anyone can see anyway to make this work more effectively please let me know.

    View code:

    SELECT        dbo.cmsPropertyType.dataTypeId, dbo.cmsPropertyType.Name, dbo.cmsPropertyType.Alias, dbo.cmsDataType.propertyEditorAlias
    FROM            dbo.cmsPropertyType LEFT OUTER JOIN
                             dbo.cmsDataType ON dbo.cmsPropertyType.dataTypeId = dbo.cmsDataType.nodeId
    

    Dapper Code (Requires Dapper nuget)

    /// <summary>
        /// Service to retrieve database custom view values
        /// </summary>
        public class CustomViewService
        {
            /// <summary>
            /// Return a custom view with the datatype relationships in them as no
            /// service provided by umbraco matches these up.
            /// </summary>
            /// <returns></returns>
            public List<DataTypePropertyRelationship> GetDataTypeProperties()
            {
                try
                {
                    IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString);
                    //Manually need to open and close the connection
                    db.Open();
                    string SqlString = "SELECT * FROM [vwDataTypePropertyRelationship]";
                    var dataProperties = (List<DataTypePropertyRelationship>)db.Query<DataTypePropertyRelationship>(SqlString);
                    db.Close();
                    return dataProperties;
                }
                catch(Exception e)
                {
                    //Logging required
                    return new List<DataTypePropertyRelationship>();
                }
            }
        }
    

    Dto

    public class DataTypePropertyRelationship
    {
        public int dataTypeId { get; set; }
        public string Name { get; set; }
        public string Alias { get; set; }
        public string PropertyEditorAlias { get; set; }
    }
    

    Cheers,

    M

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 03, 2018 @ 09:54
    Dave Woestenborghs
    2

    Hi Marc

    This package will show you how your datatypes are being used in doctypes :

    https://our.umbraco.com/packages/developer-tools/diplo-god-mode/

    And many more stuff. Maybe have a peek in the source code of that package to see how it's being handled there.

    Dave

  • MarcC 49 posts 356 karma points
    Dec 03, 2018 @ 13:31
    MarcC
    0

    Superb, thanks Dave

    M

Please Sign in or register to post replies

Write your reply to:

Draft