AI OnAI Off
public virtual string Heading { get { return this.GetPropertyValue(p => p.Heading) ?? PageName; } set { this.SetPropertyValue(p => p.Heading, value); } }
Hope this helps.
Frederik
Just wanna add to what Frederik just wrote, you need to import the EPiServer.Core namespac aswell, since those methods are extension methods. However this will not work if you're using webforms and the property webcontrol.
This is a working solution if you're on webforms:
[PagePlugIn( "Property fallbacks", "Handles fallbacks for properties on a global basis.")] public class PropertyFallbacks { private static Hashtable FallbackProperties { get; set; } public static void Initialize(int optionFlags) { PropertyDataCollection.GetHandler = FallbackPropertyHandler; FallbackProperties = new Hashtable { { "PageHeading", "PageName" } }; } public static PropertyData FallbackPropertyHandler(string name, PropertyDataCollection properties) { var data = properties.Get(name); if (data != null && (!data.IsNull || data.IsMetaData)) { return data; } var dataFromOtherPage = PropertyGetHandler.FetchDataFrom(name, properties); if (dataFromOtherPage != null && dataFromOtherPage.Value != null) { return dataFromOtherPage; } if (FallbackProperties.ContainsKey(name)) { var dataFallback = FallbackPropertyHandler(FallbackProperties[name].ToString(), properties); if (dataFallback != null && dataFallback.Value != null) { return dataFallback; } } return DynamicPropertyCache.DynamicPropertyFinder.FindDynamicProperty(name, properties) ?? data; } }
This might also be interesting http://tedgustaf.com/blog/2014/11/fallback-property-values-in-episerver-using-attributes/.
On the standard page we have a property Heading, which is editable on page. How can I set the Heading property to fallback to PageName (if Heading is not set) on all the existing pages (site updated from 6 to 7.5x)