You are viewing beta documentation for Hyper 3.x.
Reference

Link

In templates you work with a hydrated Link object — a read-time view of one saved link row. Serialized content is stored as a LinkInstance DTO on the owner element; Hyper hydrates it through Links::createLinkFromInstance().

For the field value wrapper (single vs multi-link), see LinkCollection.

Architecture

Hyper separates link type definitions (field settings) from link instances (saved content):

LayerClassRole
DefinitionLinkTypeDefinitionOne row in the Hyper field’s link type settings (handle, layout, enabled)
Settings ownerLinkTypeSettingsCP-only Element used as the field layout owner when designing link types
RegistryLink subclasses (Url, Entry, …)Type behaviour: URL resolution, element queries, empty rules
ContentLinkInstanceSerialized JSON on the owner element — linkTypeHandle, linkValue, attributes, custom fields
Field valueLinkCollectionIterable field value; hydrates Link objects for templates

Saved content never stores a Craft Element row per link. Link type settings (label, sources, layout config) live on the field definition — see Link Type Settings.

Saved content uses linkTypeHandle to identify the link type. Content JSON stores the handle, link value, attributes, and custom field values keyed by layout element UID.

Attributes

AttributeDescription
typeLink type class name, e.g. verbb\hyper\links\Entry.
linkTypeSettings prototype for this link’s handle.
urlResolved href value. Supports .env variables, aliases, prefix/suffix.
textDerived link label. Element links use the linked element’s title when Link Text is empty (after layout defaults).
targetReturns _blank when the link opens in a new window.
newWindowWhether the link opens in a new window.
linkUrlRaw link URL before full resolution.
linkUriURI segment for element-based links.
linkValueType-specific stored value (string, element id, etc.).
linkTextResolved label before text applies fallbacks.
customLinkTextAuthor-entered Link Text only — null when blank. Use text for the full derived label.
ariaLabelValue for aria-label.
urlSuffixSuffix appended to the URL (?query, #fragment).
linkTitleValue for title.
classesValue for class.
customAttributesCustom HTML attributes.

Methods

MethodDescription
getElement(status)Linked element for element-based types. Default status: live only.
hasElement(status)Whether an element is linked.
getLink(attributes)Render an <a> tag. Pass attributes to override defaults.
getLinkAttributes(attributes, asString)HTML attributes for the anchor.
getCustomLinkText()Link Text field value only (null when blank).

Element links extend the base link object (Entry, Category, Asset, etc.).

Attributes

AttributeDescription
linkSiteIdSite ID of the linked element.

Methods

MethodDescription
getElement(status)The linked Craft element.
hasElement(status)Whether a target element is set.

Element links resolve URL and text from batch-primed elements and hyper_links relation rows. See Element Links and Eager Loading.

Developers

// Hydrate content
Hyper::$plugin->getLinks()->createLinkFromInstance($field, $instance);

// Settings prototype
Hyper::$plugin->getLinks()->createSettingsPrototype($config);

// Field definitions
$field->getLinkTypeDefinitions();
$field->getLinkTypeSettingsOwners();

See Link Types for custom link type registration.