Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Making a built-in-property required by pagetype

Vote:
 

Been trying to make the "Expire date" property (stoppublish) required for a specific page type (or all of them for that matter)

Found this nice blog post from Kalle and ended up with code looking like this:

    public class SiteMetadataExtender : IMetadataExtender 
    { 
        public void ModifyMetadata(ExtendedMetadata metadata, IEnumerable attributes) 
        { 
            foreach (ExtendedMetadata property in metadata.Properties) 
            {
                if ((property.PropertyName == "TeaserText" || property.PropertyName == "iversionable_stoppublish") && property.Parent.Model is CalendarPage) 
                { 
                    property.IsRequired = true;
                } 
            } 
        } 
    }

 

This works for the "TeaserText" property that I have defined myself on the CalendarPage but the built-in "iversionable_stoppublish" gets ignored. 

So is there some magic that I'm missing when working with the built-in properties?

#119612
Mar 31, 2015 15:01
Vote:
 

Hi, Petter,

My guess is it doesn't work for built-in properties. The workaround is to implement IValidate interface for the specific page type and to do your share of checking. Not sure if this is good enough for you. 

BR,

Marija

#119620
Edited, Mar 31, 2015 16:19
Vote:
 

Seems you are right.

The IValidate workaround worked. Thanks!

Would be nice to be able to get the property to show up on the required page when creating a new one. Will add a  bug for this.

#119664
Apr 01, 2015 10:29
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.