API Reference: NodePickerAttribute Class
The NodePickerAttribute
can be applied to content model properties. The attribute specifies that a node picker editor should be used for the property in the back office.
The content model property type must be either IContentType
-derived, IPublishedContent
, or string
, or a collection thereof. In the case of a string type, only the node id will be returned. For IPublishedContent
and node ids, the content view model can be retrieved with the ModelAsync()
or ModelsAsync()
methods on the IRedaktContext
object or the current content view model.
If NodePickerAttribute
is not specified, and no other attribute that sets a content editor is specified, the content editor will be inferred from the property type. A node picker editor will be automatically selected if the property type is IPublishedContent
, but not for the other allowed property types (string and IContentType
-derived).
Usage
Decorate the content model property with the NodePickerAttribute
. The attribute does not have any properties. The AllowContentTypeAttribute
can be used to restrict the content types that may be selected by the node picker.
Example
[Page]
public class BlogOverview: IContentType
{
// Selectable pages are restricted to BlogArticle type nodes
[NodePicker]
public ICollection<BlogArticle> Articles { get; set; }
// Editor will be node picker by convention (for IPublishedContent types)
[AllowedContentType(typeof(BlogArticle))]
public IPublishedContent HighlightedArticle { get; set; }
}