November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
At first glace the code all looks good. Your initialisation module may be initilaising too early though, so try adding the following depedency onto your init module:
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Cms.Shell.InitializableModule))]
public class MetadataExtenderModule : IInitializableModule
{
...
Thank David Knipe,
My current codes can replace caption of properties with type IList<string>, the other property with types, which are int, bool, string are not able to replace. I don't know why.
I added your code to project but it doesn't replace other properties
[ModuleDependency(typeof(EPiServer.Cms.Shell.InitializableModule))]
Hi David Knipe,
You was right. My initialisation module is initilaised too early. After I changed value PropertyMetadata.DisplayName, at some point, my PropertyMetadata.DisplayName (changed value) was replaced by translation text in resource file. Therefore I went to different approach by creating EditorDescriptor like below code but it is not help. The EditorDescriptor can display closest Startpage name if there is no translation text of that property in resource file. If there is translation text, Display name will be replaced by translation text. I thought it was EditorDescriptor but it is not. Do you know where final DisplayName is set?
[EditorDescriptorRegistration(TargetType = typeof(String), UIHint = Global.SiteUIHints.String, EditorDescriptorBehavior = EditorDescriptorBehavior.PlaceLast)]
public class InheritParentNameEditorDescriptor : EditorDescriptor
{
IContentRepository _contentRepository;
public InheritParentNameEditorDescriptor()
{
_contentRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentRepository>();
}
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
base.ModifyMetadata(metadata, attributes);
var contentDataMetadata = (ContentDataMetadata)metadata;
var standardPage = contentDataMetadata.Parent.Model as StandardPage;
if (standardPage != null)
{
StartPage parentPage = GetClosestStartPage(standardPage.ParentLink);
metadata.DisplayName = string.Format(metadata.DisplayName, parentPage.Name); //string.Format("Lorem Ipsum {0}", "Fruit") => "Lorem Ipsum Fruit"
}
}
private StartPage GetClosestStartPage(PageReference pageRef)
{
PageData page = null;
_contentRepository.TryGet(pageRef, out page);
var closestStartPage = page as StartPage;
if (closestStartPage == null)
{
GetClosestStartPage(page.ParentLink);
}
return closestStartPage;
}
}
public class StandardPage : SitePageData
{
[UIHint(Global.SiteUIHints.String)]
public virtual string TestString { get; set; }
}
Hi guys,
In edit mode, when all properties panel is displayed, each property show caption. Is there anyway to change properties caption at runtime? In example, page Apple is child page of page Fruit. In page Apple, there is property with caption "Lorem ipsum {0}", at runtime, I want to replace {0} by Fruit. The caption will look like "Lorem ipsum Fruit".
Here what I have done until now
But in edit mode, property "loremIpsum" still display caption "Lorem Ipsum {0}".
Could you please to help me to fix this? Where did I do wrong?
Thank in advance,
Linh