Reference

Node

A Node object represents a single item in a navigation menu tree — a link, a linked Craft element, or a structural item such as a group or Dynamic node. When you work with nodes in Twig or PHP, you are usually dealing with a verbb\navigation\elements\Node object.

Properties

id

Type: int|null

Node element ID

elementId

Type: int|null

Linked Craft element ID (element-backed nodes)

element

Type: craft\base\ElementInterface|null

Linked Craft element — lazy-loaded; use withLinkedElements() on the query to batch-load

Type: int|null

Parent menu ID

Type: verbb\navigation\elements\Menu|null

Parent Menu element — use withMenu() on the query to batch-load

url

Type: string|null

Full URL (linked element or custom)

nodeUri

Type: string

URI portion relative to the site

title

Type: string|null

Node title

type

Type: string|null

Node type class name (e.g. verbb\navigation\nodetypes\Entry)

classes

Type: string|null

CSS classes string

customAttributes

Type: array

Table of { attribute, value } rows

urlSuffix

Type: string|null

Per-site suffix (anchor path, query string)

newWindow

Type: bool

Open in new window

target

Type: string

_blank or empty string

status / enabled / enabledForSite

Element status

children

Type: craft\elements\db\ElementQueryInterface|craft\elements\ElementCollection

Child nodes — wired in memory when hierarchy is enabled

level

Type: int|null

Structure level

siteId

Type: int|null

Node site variant

Node custom fields (on the menu’s node field layout) are available by handle like any Craft element.

Active State

getCurrent()

Returns: bool

Exact URL match

getActive()

Returns: bool|null

Current, path-section, or has active descendant

hasActiveChild()

Returns: bool

Descendant nav node is current (bool)

getActiveState()

Returns: verbb\navigation\models\NodeActiveState

Underlying state object

See Active State & Context.

Methods

getTag()

Returns: string

HTML tag for this node type (a, span, …)

getTypeLabel()

Display name for the node type

Returns: Twig\Markup|null

Full HTML anchor (or appropriate tag) with title

getLinkAttributes($extra)

Returns: Twig\Markup

Rendered attribute string for custom markup

isElement()

Returns: bool

Element-backed node

isCustom()

Returns: bool

Custom URL node

isPassive()

Returns: bool

Passive (non-link) node

isSite()

Returns: bool

Site node

isGroupColumn()

Returns: bool

Group/column structural node

linkAttributes

<a {{ node.linkAttributes({
    class: 'nav-link',
}) }}>{{ node.title }}</a>

Merges node classes, target, rel, and custom attributes with any extras you pass.

customAttributes

This property contains the authored { attribute, value } rows. Use linkAttributes when rendering them into HTML so Navigation evaluates the values and applies its supported attribute rules.

Linked Element Fields

{% if node.element %}
    {{ node.element.someFieldHandle }}
{% endif %}

Use withLinkedElements() on the parent query to avoid N+1 loads.