Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Maybe you can hide the property if placed in PageHeader?
if (metadata.GroupName == SystemTabNames.PageHeader)
{
metadata.ShowForEdit = false;
metadata.ShowForDisplay = false;
}
Oh, btw, you can hide the default page header with this editor descriptor:
[EditorDescriptorRegistration(TargetType = typeof(string))]
[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = "previewabletext")]
[EditorDescriptorRegistration(TargetType = typeof(bool))]
[EditorDescriptorRegistration(TargetType = typeof(bool?))]
[EditorDescriptorRegistration(TargetType = typeof(AccessControlList))]
public class HideAllPageHeaderProperties : EditorDescriptor
{
private static IEnumerable<string> _pageHeaderPropertyNames = new[]
{
"iroutable_routesegment",
"icontent_name",
"PageExternalURL",
"PageVisibleInMenu",
"PageTypeName",
"ACL"
};
private static IEnumerable<string> _allowedRoles = new[]
{
"CmsAdmins",
"Administrators"
};
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
base.ModifyMetadata(metadata, attributes);
if (IsDefaultPageHeaderProperty(metadata.PropertyName) && !_allowedRoles.Any(EPiServer.Security.PrincipalInfo.CurrentPrincipal.IsInRole))
{
metadata.ShowForEdit = false;
metadata.ShowForDisplay = false;
}
}
private static bool IsDefaultPageHeaderProperty(string propertyName)
{
return _pageHeaderPropertyNames.Any(name => name.Equals(propertyName, StringComparison.OrdinalIgnoreCase));
}
}
Hi All
I am using IMetadataAware to restrict access to certain properties on content types, although when using an example i found from Linus it doesnt seem to work if the property is located in the SystemTabNames.PageHeader tab
The code i am using is as follows :
And to restrict at Property Level i am doing
Just to confirm when i use on any other property not in that specific tab it works just fine. Any Help would be appreciated
Also for some bonus points is their anyway i can completely restrict access to SystemTabNames.PageHeader or Hide it ? Via admin mode i tried setting access right to administer only and it took no effect
Cheers
Minesh