Can I set a property without saving page when page is loaded

Vote:
 

Is there a way that my "Heading" property can be set to the value of the "PageName" when I start editing a previously published page without having to save the page with this new value?

#91230
Sep 30, 2014 13:36
Vote:
 

If I understand you correctly... You can actually change how properties are fetched by implementing your own handler for PropertyDataCollection.

The following code will set PageName to be fallback for PageHeading. However, this will be true for all instances of PageHeading on all content types. But that's usually what you want in this case.

[PagePlugIn]
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;
    }
}
#91242
Sep 30, 2014 18:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.