Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1383 posts 3233 karma points c-trib
    Dec 19, 2018 @ 12:07
    Simon Dingley
    0

    Accessing Doctype Properties in Custom ListView Layout

    Did anything change in recent versions relating to the data available in a ListView?

    I am trying to put together a custom layout and seem to not have access to any of the values on the document properties for each item in the $scope.items collection.

    enter image description here

    If that is the way it is now then I guess I just have to make additional calls out to get them but the below seems a bit of a weighty solution to that?

        angular.forEach($scope.items,
            function(item) {
                contentResource.getById(item.id)
                    .then(function(ent) {
                        var imgProp = _.find(ent.properties, function (p) { return (p.alias === "image"); });
                        item.excerpt = _.find(ent.properties, function (p) { return (p.alias === "excerpt"); }).value;
                        mediaResource.getById(imgProp.value)
                            .then(function(media) {
                                item.image = mediaHelper.resolveFile(media, false) + "?width=400&height=240&mode=crop";
                            });
                    });
            });
    

    Is anyone doing this differently or more elegantly?

  • MB 66 posts 261 karma points
    Dec 19, 2018 @ 13:21
    MB
    0

    Not ListView per-se, but I was recently working on a similar issue and found I quickly hit the point where the number of requests was impacting performance so much that I was better served writing a resourcePromise using umbRequestHelper to an UmbracoAuthorizedJsonController, do all the work there with the C# API, and pass back a resultSet object.

  • Simon Dingley 1383 posts 3233 karma points c-trib
    Dec 21, 2018 @ 16:22
    Simon Dingley
    0

    I'm not at that point yet but thanks for the heads up. I am sure the property data used to be available but perhaps for the same reasons you found that is no longer the case.

Please Sign in or register to post replies

Write your reply to:

Draft