Skip to content

Read nested values and build tokens

Use sub-field machine names. With a loaded Conference node and a populated first field_sessions item:

$session = $node->get('field_sessions')->get(0);
$title = $session->get('title')->get('value')->getValue();
$session->get('title')->get('value')->setValue('Opening keynote');
$violations = $node->validate();
if ($violations->count() !== 0) {
  throw new \RuntimeException('Check the conference values before saving.');
}
$node->save();
Path from one session Value
title.value String
link.uri, link.title Link URL and label
description.processed Filtered text
track.target_id, track.entity Term ID and referenced entity
topics.1.value Second capped topic
speaker.person.value Nested speaker name

Capped values belong to their outer item. Check for empty items and references before dereferencing. Database names such as title__value are not typed-data paths.

Tokens

With Token enabled, select values in its token browser:

[node:field_sessions:0:title:value]
[node:field_sessions:0:topics:1:value]
[node:field_sessions:0:track:entity:name]

The browser also lists date formats and image styles for installed field types.

Search API

On the host content index's Fields screen, expand the compound and select named sub-fields. Expand a reference's entity for target properties. Avoid flattened columns, whose names can change with the schema.

Indexing repeated compounds collects values across items. Ordinary search fields lose the association between a topic and its session; design filters accordingly.

See the Field API to create compounds and the wire format for serialized requests.