Copied to clipboard

Flag this post as spam?

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


  • Umbraco Newbie 22 posts 124 karma points
    Aug 24, 2017 @ 13:44
    Umbraco Newbie
    0

    Editor Access To Setting BUT only Dictionary

    Hi

    Is it possible to give the editor access to only the dictionary items in settings?

    Thanks George

  • Jan Bengtsson 64 posts 107 karma points
    Aug 25, 2017 @ 12:23
    Jan Bengtsson
    0

    Hi,

    I'm also interested in this one. We need to give one of our customers access to the Languages and Dictionary folders in the Settings section. But for safety's sake we would like to hide or prevent access to the rest of the Settings tree. Is that possible?

    • Jan
  • Doobear 21 posts 111 karma points
    Sep 18, 2017 @ 15:34
    Doobear
    0

    There is a great little package for this which adds a dictionary editor and Import/Export to the Dashboard.

    https://our.umbraco.org/projects/backoffice-extensions/dictionary-dashboard/

    It didn't work with v 7.6.x but found this great little fix.

    https://our.umbraco.org/projects/backoffice-extensions/dictionary-dashboard/feedback/52797-Umbraco-710

    Thanks to Dennis Milandt for this invaluable package.

  • Marcio Goularte 388 posts 1360 karma points
    Sep 18, 2017 @ 19:55
  • George Phillipson 108 posts 287 karma points
    Oct 04, 2017 @ 22:12
    George Phillipson
    0

    Bit late to this one, but if anyone wants to allow the editor to add custom error messages, then you can use the code below. It does not use the dictionary but gets the property values from doc type.

    In may case I have a contact form the client wanted, named 'contact' so code is below.

    using Umbraco.Core.Models;
    using Umbraco.Web;
    
    namespace UmbracoPropertyValueValidation
    {
        public static class UmbracoPropertyValidationHelper
        {
            public static string GetPropertyValueItem(string key)
            {
                UmbracoHelper umbracoHelper     = new UmbracoHelper(UmbracoContext.Current);
                IPublishedContent currentPage   = umbracoHelper.AssignedContentItem;
    
                if (currentPage.DocumentTypeAlias.ToLower() == "contact")
                {
                    string errorMessage = currentPage.GetPropertyValue<string>(key);
    
                    return errorMessage;
                }
                return null;
            }
        }
    }
    

    This code validates string length, but you can easily modify it for required fields etc.

        using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Text;
    using System.Web.Mvc;
    
    namespace UmbracoPropertyValueValidation
    {
        public class UmbracoGetPropertyValueStringLength : StringLengthAttribute, IClientValidatable
        {
            private readonly string _errorMessageKey;
            private readonly string _errorFieldName;
    
            public UmbracoGetPropertyValueStringLength(string fieldName, string errorMessageKey, int maximumLength) : base(maximumLength)
            {
                _errorMessageKey    = errorMessageKey;
                _errorFieldName     = fieldName;
    
            }
    
            public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
            {
                ErrorMessage = UmbracoPropertyValidationHelper.GetPropertyValueItem(_errorMessageKey);
    
                var error   = FormatErrorMessage(metadata.DisplayName);
                StringBuilder sb = new StringBuilder(error);
                sb.Replace("[Min]", MinimumLength.ToString());
                sb.Replace("[Max]", MaximumLength.ToString());
                string newErrorMessage = sb.ToString();
    
                var rule    = new ModelClientValidationStringLengthRule($"{_errorFieldName} {newErrorMessage}", MinimumLength, MaximumLength);
    
                yield return rule;
            }
        }
    
    }
    
    
    Now in viewmodel:
    
    
    [UmbracoGetPropertyValueDisplayName("messageDisplayTitle")]
            [UmbracoGetPropertyValueRequired("messageRequired")]
            [UmbracoGetPropertyValueRegularExpression("Message", "errorOnlyAlphaNumericCharactersAllowed", "^[0-9a-zA-Z .]+$")]
            [UmbracoGetPropertyValueStringLength("Message","errorMessageStringLength", 250, MinimumLength = 5)]
    

    Where errorMessageStringLength is property in my doc type.

    And the error message is: Message must be between 5 and 250 characters

    Hope someone finds it helpfull

    George

    In case anyone is interested, I have created a small project for getting validation messages from Umbraco using properties.

    The link is https://github.com/GeorgePhillipson/CustomValidation and if anyone wishes to add or modify it, feel free.

  • Nathan Woulfe 447 posts 1665 karma points MVP 5x hq c-trib
    Oct 05, 2017 @ 00:29
    Nathan Woulfe
    0

    Another option would be to use an AngularJs httpInterceptor to modify the section tree - catch the response from GetApplicationTrees, then modify the children array to remove the unwanted tree nodes.

    We do this in a few different places to modify the backoffice experience for our editors, can be really useful.

    Quick explanation and example: http://nathanw.com.au/blog/customising-umbraco-without-touching-core-files/

  • Vladimir Knobel 95 posts 171 karma points
    Oct 25, 2018 @ 12:24
Please Sign in or register to post replies

Write your reply to:

Draft