-
Notifications
You must be signed in to change notification settings - Fork 27
Keeping references between pages to track dependencies of content
By default, Puck tracks references in your content to other content by processing any List<PuckPicker>
properties (i.e. Content Picker or Image Picker properties) with a property Transformer. you can find out if a page is referenced by another by going to the edit page in the backoffice for any given content and checking the References
field on the default
tab.
so while references for Content Pickers and Image Pickers are kept by default, for string fields like a Rich Text Editor you will need to opt in by decorating your properties/ViewModels with a StringReferencesTransformer
attribute. here's an example:
[StringReferencesTransformer(Properties = new string[] { nameof(Homepage.MainContent),nameof(Homepage.IntroParagraph) })]
public class Homepage:Page
{
[Required]
[UIHint(EditorTemplates.RichTextEditor)]
[Display(Name="Main Content",GroupName ="Content")]
[IndexSettings(FieldIndexSetting = Field.Index.ANALYZED, Analyzer = typeof(SnowballAnalyzer))]
public string MainContent { get; set; }
[UIHint(EditorTemplates.RichTextEditor)]
[Display(Name="Intro Paragraph",GroupName ="Content")]
public string IntroParagraph { get; set; }
}
in this example, the Transformer
is on the ViewModel but you could just as well decorate a property with the attribute. the Properties
field is set to specify which properties should be processed.