They are virtual, so you could override them:
[CultureSpecific]
public override bool VisibleInMenu { get; set; }
However, "SortOrder" is an internal metadata property. I doubt you could make that culture specific.
Hi Per
I tried to override the VisibleInMenu property and it just duplicated the property. I ended up having two properties with the same name.
Any other suggestions on how we can achieve culture specific sort order and visible in menu ?
I have the same problem as Sayeed, doing like Per Magne saying dublicates the property.
Any updates on this?
Here is a thing you could try (at your own risk!!!):
Create a new property:
[Display(Name = "Display in navigation", GroupName = "EPiServerCMS_SettingsPanel", Order = 2)] [CultureSpecific] public virtual bool VisibleinMenuHack { get; set; }
You can replace the built in VisibleInMenu property with the VisibleInMenuHack property. Notice the GroupName? This will put the property in the settings area. An IMetaDataExtender is needed in order to hide the old one from edit mode:
public class SiteMetadataExtender : IMetadataExtender { public void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes) { foreach (ExtendedMetadata property in metadata.Properties) { if (property.PropertyName == "PageVisibleInMenu") { property.ShowForEdit = false; } } } }
Then, the IMetadataExtender must be registered:
[InitializableModule] [ModuleDependency(typeof (EPiServer.Cms.Shell.InitializableModule))] public class SiteMetadataExtenderInitialization : IInitializableModule { public void Initialize(InitializationEngine context) { if (context.HostType == HostType.WebApplication) { var registry = context.Locate.Advanced.GetInstance<MetadataHandlerRegistry>(); registry.RegisterMetadataHandler(typeof(ContentData), new SiteMetadataExtender()); } } public void Preload(string[] parameters){} public void Uninitialize(InitializationEngine context) { } }
Now they are swapped - but the value from the old property will still be used by the system, whenever lists are rendered and such. So here is the last part of the puzzle(might be risky!!):
On your content model, make sure that whenever the value for the old property is fetched, the property from VisibleInMenuHack is fetched instead:
[Ignore] public override object this[string index] { get { if (index == "PageVisibleInMenu") { return VisibleinMenuHack; } return base[index]; } set { base[index] = value; } }
... And you should have a culture specific "VisibleInMenu". I suppose you could do the same for SortOrder
What you might do is hide the built-in property with an editor descriptor and create a new one that is culture specific:
[EditorDescriptorRegistration(TargetType = typeof(bool))] [EditorDescriptorRegistration(TargetType = typeof(bool?))] public class HideVisibleInMenuEditorDescriptor : EditorDescriptor { public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes) { base.ModifyMetadata(metadata, attributes); if (metadata.PropertyName == "PageVisibleInMenu") { metadata.ShowForEdit = false; } } }
Now, I am not sure if there is a way to force the new property to be shown in the grey area, I think I saw a blog or forum post on it, but I cannot find it now.
This does not really fix the problem, especially with sort order.
BR,
Marija
Btw, here is how to move a property to the "grey area" http://world.episerver.com/blogs/Kalle-Ljung/Dates/2013/10/Moving-built-in-properties-to-the-settings-header-in-EPiServer-7-CMS/
And I have written a slightly simpler example that works for Episerver CMS 7.5 and later:
Is there a way to override built-in page type properties. I am working on a multi-lingual website and I want to make certain properties like SortOrder, VisibleInMenu, etc to be CultureSpecific?