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?
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.
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.
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
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?
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.
Create custom section
http://www.theoutfield.co.uk/blog/2014/08/moving-the-dictionary-tree-to-a-different-section-in-umbraco
https://github.com/netaddicts/umbraco-dictionary-section
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.
This code validates string length, but you can easily modify it for required fields etc.
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.
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/
This is the answer you are looking for: https://our.umbraco.com/packages/backoffice-extensions/diplo-dictionary-editor/
is working on a reply...