Tags: CMS12 Optimizely CMS

The new LinkItem property in Optimizely CMS, and why it matters

In Optimizely CMS, content is stored as blocks, pages, and media - all of which can be referred to as content. Content is built using different properties of built-in or custom property types.

In the past

A single link item has been a much-wanted property type for years. We had different options, each with its own limitations. These options include:

Url: Link dialog with drag and drop support. Internal and external links.

public virtual Url Url { get; set; }

PageReference: Content picker with drag and drop support. Internal links only.

public virtual PageReference PageReference { get; set; }

Neither Url nor PageReference may specify a Link text. You can of course do this with a separate property, like this. But it's far from optimal.

public virtual string LinkText { get; set; }

LinkItemCollection: Link to multiple external and/or internal resources. Can be limited to 1 item.

[ListItems(1)]
public virtual LinkItemCollection LinkItemCollection { get; set; }

Using the LinkItemCollection you may specify the LinkText, but the property is designed to work with a list of links, not a single link.

Then, a Labs package

In 2020, Grzegorz Wiecheć, of Optimizely, releases an Episerver Labs package that adds a LinkProperty with a single link and a link text.

It worked great, but Labs packages are unsupported and may change at any time. Because of this, you should show some caution when adopting them in your project.

Finally, built-in support

In September 2022, the LinkItem property is finally built-in in CMS 12.

You may add it to your content type like this.

public virtual LinkItem LinkItem { get; set; }

And it works like a Url property with extra fields for Link text and Link title.

Graphical user interface, application

That's it!

Found this post helpful? Help keep this blog ad-free by buying me a coffee! ☕