Copied to clipboard

Flag this post as spam?

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


  • Stefan Stankovic 12 posts 119 karma points
    Aug 22, 2023 @ 11:55
    Stefan Stankovic
    0

    Block Grid Backoffice custom View and Controller

    Hi,

    I've been using this article to create a custom view and a controller for a block grid module: https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/block-editor/build-custom-view-for-blocks

    Locally everything works fine. But on the customer's server the code won't load the controller. There is the error message:

    Error: [$controller:ctrlreg] http://errors.angularjs.org/1.8.3/$controller/ctrlreg?p0=talkingNumbersController
    at umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:25:168
    at umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:117:19
    at ea (umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:99:20)
    at p (umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:90:355)
    at g (umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:84:186)
    at umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:83:311
    at Object.link (umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:321:432)
    at umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:35:134
    at Ca (umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:108:361)
    at p (umbraco-backoffice-js.js.vc7a02dd82c4a1090938c6f8a3574dc6569747a0f:92:340) `<div style="display:contents;" ng-class="{'show-validation': vm.blockEditorApi.internal.showValidation}" ng-include="api.internal.sortMode ? api.internal.sortModeView : '/App_Plugins/UmbracoBlockGrid/BlockViews/talkingnumbers.html'">`
    

    Here is my controller:

    angular.module("umbraco").controller("talkingNumbersController", function ($scope, $routeParams, contentResource, contentEditingHelper) {
    // code
    });
    

    My view:

    <div
     ng-controller="talkingNumbersController as vm"
     ng-click="block.edit()"
     ng-focus="block.focus"
     ng-class="['talking-numbers', model.themeClass]">
    <!-- HTML -->
    </div>
    

    Package manifest:

    {
      "javascript": [
    "~/App_Plugins/UmbracoBlockGrid/BlockControllers/talkingnumbers.controller.js?v=202308181926"
      ]
    }
    

    I found out that there is a difference between my development config and configuration on the server so I started to remove one by one difference. The module started working after removing the following configuration:

    {
      "Umbraco": {
        "CMS": {
          "Hosting": {
            "Debug": true
          }
        }
      }
    }
    

    There is an article that explains what the property does, but I can't figure out how to adapt my code to work if the Debug property is false.

    https://docs.umbraco.com/umbraco-cms/fundamentals/code/debugging/

    EDIT: The Umbraco version where the problem occurs is 12.1.1

  • Damian 66 posts 389 karma points
    Aug 22, 2023 @ 20:05
    Damian
    0

    I believe the root issue comes down to caching which the debug flag effectively disables. I'm in a hurry so cannot fully verify/vet this but the issue sounds familiar (time and time again!) and i believe that deleting /umbraco/Data/TEMP/ will do the magic. The /DistCache specifically but, again, all from the hip on this one! Hope it helps point in the right direction

  • Stefan Stankovic 12 posts 119 karma points
    Aug 23, 2023 @ 06:21
    Stefan Stankovic
    0

    Hi Damian, I've deleted the TEMP folder but it doesn't fix the issue.

  • Stefan Stankovic 12 posts 119 karma points
    Sep 07, 2023 @ 09:06
    Stefan Stankovic
    100

    I found what was the problem with this error. If Hosting isn't set on Debug mode, Umbraco reads file content and creates one unified file to be able to minify it. A path with a version to the end can't be read by File.IO "~/App_Plugins/UmbracoBlockGrid/BlockControllers/talkingnumbers.controller.js?v=202308181926", so removing ?v=202308181926 fixed the problem.

  • Chris Van Oort 110 posts 371 karma points
    Feb 16, 2024 @ 16:41
    Chris Van Oort
    0

    We ran into this problem as well and didn't have a version number on our controllers in the package.manifest file.

    However, what did work for us was stopping the website and then deleting the Smidge\Cache folder (remove the whole cache folder), then restart the website.

Please Sign in or register to post replies

Write your reply to:

Draft