The link editor renders a control for selecting internal (referenced within Redakt) or external links. The editor displays an input field with the currently set link.

When the user clicks on the editor's browse button, a dialog is displayed allowing the user to select an internal or external link, optionally setting the link title, language to link to (for internal links on multilanguage sites), and whether to open the link in a new tab.

The link editor can only be used for properties of type Link, and is also the default editor for them. The editor also supports collection-based properties, in which case a sortable list of links is rendered.

Single link (empty)
Sortable list of Links
Select internal link dialog
Set external link dialog

Usage

The link editor is the default editor for Link objects, and cannot be used for other types. You can set additional configuration by decorating the property with the LinkEditorAttribute:

Internal links only

You can disable the selection of external links by setting the OnlyInternalLinks property of the LinkEditorAttribute to true. This will remove the internal/external radio buttons and allows the selection of internal links only.

Disable name field

You can disable setting the link name/title field by setting the DisableNameField property of the LinkEditorAttribute to true. This will remove the name input field from the dialog.

Disable target field

You can disable setting the link target by setting the DisableTargetField property of the LinkEditorAttribute to true. This will remove the "open in new tab" checkbox.

Link object

After setting a link in the link dialog, the content property value is set to a Link object instance. The Link object contains the following properties:

  • Url - the external URL that was set by the user. For internal links, this value is null.
  • PageId - the node id of the internal page that was selected by the user. For external links, this value is null.
  • Title - the title set by the user in the title input field.
  • TargetFrame - the target frame set by the user. "_blank" if the "open in new tab" checkbox was checked, otherwise null.
  • TargetCultureName - the target culture name set by the user in the culture dropdown, or null if no specific culture was selected.

In your Razor views, the Link object can be passed to the rx-href attribute of the Anchor Tag Helper to automatically generate the correct URL based on the Link object properties.

Example

[Page]
public class ContentPage: IContentType
{
    // Uses the default link editor.
    public Link ReadMore { get; set; }
    
    // Only allows internal links.
    [LinkEditor(OnlyInternalLinks = true)]
    public Link InternalLink { get; set; }
    
    // Sortable list of links.
    public IReadOnlyList<Link> MoreArticles { get; set; }
}