Try our conversational search powered by Generative AI!

Loading...
Area: Optimizely CMS
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

An important feature of a CMS is the ability to create links to other content. An example of this is the ability to be able to select a page in a page reference property. This functionality has been generalized to work with other content types as well. The following examples shows different way to set up content selection properties.

Built-in content selectors

The following samples shows some built in content selectors:

public virtual PageReference PageReference { get; set; }

[UIHint(UIHint.Block)]
public virtual ContentReference BlockReference { get; set; }

[UIHint(UIHint.Image)]
public virtual ContentReference ImageReference { get; set; }

[UIHint(UIHint.Video)]
public virtual ContentReference VideoReference { get; set; }

[UIHint(UIHint.MediaFile)]
public virtual ContentReference AnyMediaFileReference { get; set; }

[UIHint(UIHint.BlockFolder)]
public virtual ContentReference BlockFolderReference { get; set; }

[UIHint(UIHint.MediaFolder)]
public virtual ContentReference MediaFolderReference { get; set; }
     

Customizing selection

Beside using the built in selectors you can customize this for your own needs.

[UIHint("teaserblock")]
public virtual ContentReference TeaserBlockReference { get; set; }

[EditorDescriptorRegistration(TargetType = typeof(ContentReference), UIHint = "teaserblock")]
public class BlockReferenceEditorDescriptor : ContentReferenceEditorDescriptor<TeaserBlock>
{
    public override IEnumerable<ContentReference> Roots
    {
        get
        {
            //Sample where we are overriding the default root for the repository.
            //Reference should be taken from configuration or site initialization and not hard coded.
            return new ContentReference[] { new ContentReference(90 ) };
        }
    }
}
       
Do you find this information helpful? Please log in to provide feedback.

Last updated: Mar 31, 2014

Recommended reading