Search code examples
propertiesdefaultdefault-valueepiserverdefaultifempty

Default Meta description from other Properties (when empty) - EPiServer


I am working on an EPiServer 5 project and I need to fill in the meta-description property of my page type with data from other properties. E.g. Take the first sentence of the body and use it as meta description"

This should be done if the editor left the meta description empty. Any help on how to solve this issue?

Many thanks.


Solution

  • There is a code example how to fallback and extract text from your main body in the example project PublicTemplates (or Alloy demo site for EPiServer 6 R2 and later) that ships with EPiServer. Look at the Header.ascx.cs file.