Copied to clipboard

Flag this post as spam?

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


  • Bo Jacobsen 438 posts 1818 karma points
    Oct 26, 2020 @ 11:36
    Bo Jacobsen
    0

    How to get culture in DocTypeGridEditor

    Hi all.

    Using UmbracoCms 8.8.0 and Our.Umbraco.DocTypeGridEditor 1.2.4

    How do i get the culture?

    Is it possible through the view on the IPublishedElement ?

    There are som scenarios where i need the culture when i use a Content Picker or Multi Url Picker.

    So i created a custom property controller that are used in the grid, inserted with DocTypeGridEditor in the package.manifest like this:

    {
      "propertyEditors": [
        {
          "alias": "Custom.PropertyEditor.Culture",
          "name": "Readonly Culture",
          "icon": "icon-readonly color-red",
          "editor": {
            "view": "~/App_Plugins/CustomPlugin/propertyEditors/readonlyCulture/readonlyCulture.html"
          }
        }
      ],
      "gridEditors": [
        {
          "name": "List",
          "alias": "Custom.GridEditors.List",
          "view": "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html",
          "render": "/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml",
          "icon": "icon-bulleted-list color-green",
          "config": {
            "allowedDocTypes": [ "ListView" ],
            "nameTemplate": "",
            "enablePreview": true,
            "overlaySize": "small",
            "viewPath": "/Views/Partials/DocTypeGridEditor/",
            "previewViewPath": "/Views/Partials/DocTypeGridEditor/Previews/",
            "previewCssFilePath": "",
            "previewJsFilePath": ""
          }
        }
      ],
      "javascript": [
        "~/App_Plugins/CustomPlugin/propertyEditors/readonlyCulture/readonlyCulture.js"
      ]
    }
    

    My controller looks like this:

    (function () {
        "use strict";
    
        function readonlyCulture($scope, $routeParams) {
    
            $scope.model.value = $routeParams.cculture || $routeParams.mculture;   
        }
    
        angular.module("umbraco").controller("Custom.ReadonlyCulture.EditorController", readonlyCulture);
    })();
    

    There is a $routeParams.mculture and a $routeParams.cculture.

    When i am editing the main language i am only getting mculture as expected.

    And when i change to another language i am getting the cculture as expected.

    But when i am using splitview, i get am getting the same result on both documents.

    Example:

    URL: http://localhost:64556/umbraco/#/content/content/edit/1056?mculture=da-DK&cculture=en-US

    Split View: Left -> en-US. Right: da-DK enter image description here

    When i access the grid on both documents i am getting mculture=da-DK and cculture=en-US and can no longer tell the difference, because i do not know which one i am editing.

    I hope someone know what to do :)

    I was told that $scope.model.culture could do it, but not in DTGE. https://our.umbraco.com/forum/using-umbraco-and-getting-started/103020-how-to-get-document-culture-in-controller-to-use-in-grid-when-using-split-view

  • 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