Copied to clipboard

Flag this post as spam?

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


  • Dominic Resch 45 posts 115 karma points
    Jul 27, 2024 @ 22:35
    Dominic Resch
    0

    V13: Get items of area in custom block grid item view

    I have a block grid item which has an area (name: “main”, 12 columns).

    For this item I have a custom view for the back office. And now I want to display all items within the area, but not with “umb-block-grid-render-area-slots”.

    I just want to get all items of this area in the AngularJS controller to render them in a special way.

    How do I do that? How do I get the items in the controller?

  • Dominic Resch 45 posts 115 karma points
    Jul 28, 2024 @ 19:11
    Dominic Resch
    0

    So far I have managed to display the titles of my items in the area.

    Now I still have the problem that I somehow can't transfer the blocks to the template.

    Can anyone help me? “umb-block-grid-render-area-slots” in my tab.html just doesn't output anything.

    // tabs.html
    <div ng-controller="tabsBlockController">
        <uui-tab-group>
            <uui-tab ng-repeat="block in blocksInMainArea" ng-click="selectTab($index)">{{ getBlockTitle(block) }}</uui-tab>
        </uui-tab-group>
    
        <div>
            <div ng-repeat="block in blocksInMainArea"
                 ng-include="getBlockTemplateUrl(block)">
            </div>
        </div>
    </div>
    
    // tab.html
    <umb-block-grid-render-area-slots>
    </umb-block-grid-render-area-slots>
    
    // tabsBlock.controller.js
    angular.module("umbraco")
    .controller("tabsBlockController", function ($scope) {
        const blockGridItem = $scope.$parent.$parent.block;
    
        $scope.blocksInMainArea = blockGridItem.layout.areas.find(area => area.$config.alias === "main").items;
    
        $scope.getBlockTemplateUrl = function (block) {
            return block.$block.config.view;
        };
    
        $scope.getBlockTitle = function (block) {
            return block.$block.data.title;
        };
    });
    
  • 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