London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

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

The following built-in content selector examples show ways to set up content selector properties to create links to other content, such as selecting a page in a page reference property.

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 a selector

The following example, which you can customize, shows how to override the default root of the repository. 

[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 to override the default root for the repository.
            //Take the reference from configuration or site initialization and do not hard-code it.
            return new ContentReference[] { new ContentReference(90 ) };
        }
    }
}
        

Last updated: Feb 23, 2015