@@ -54,3 +54,90 @@ function interledger_preprocess_block__interledger_content(&$variables) {
5454 }
5555 }
5656}
57+
58+ /**
59+ * Helper function for Summit Talk and Summit Speaker nodes.
60+ */
61+ function interledger_get_summit_entity_field(\Drupal\node\NodeInterface $node, $spanish_field, $default_field)
62+ {
63+ $default_language = \Drupal::languageManager()->getDefaultLanguage()->getId();
64+ $current_language = \Drupal::languageManager()->getCurrentLanguage()->getId();
65+
66+ if ($current_language != $default_language && !$node->get($spanish_field)->isEmpty()) {
67+ return $node->get($spanish_field)->value;
68+ }
69+ return $node->get($default_field)->value;
70+ }
71+
72+ /**
73+ * Preprocesses the Summit Speaker 2025 full node
74+ *
75+ * Sets the speaker bio based on the page language.
76+ *
77+ * Uses the Spanish bio (`field_speaker_biografia`) when viewing the page
78+ * in Spanish; otherwise, or if unavailable, falls back to the default
79+ * (English) bio (`field_speaker_bio`).
80+ */
81+ function interledger_preprocess_node__summit_speaker_2025__full(&$variables)
82+ {
83+ $node = \Drupal::routeMatch()->getParameter('node');
84+
85+ $variables['bio'] = interledger_get_summit_entity_field($node, 'field_speaker_biografia', 'field_speaker_bio');
86+ }
87+
88+ /**
89+ * Preprocesses the Summit Talk 2025 full node
90+ *
91+ * Sets the Talk title and talk description based on the page language.
92+ *
93+ * Uses the Spanish title & description (`field_titulo_de_la_sesion` & `field_descripcion`) when viewing
94+ * the page in Spanish; otherwise, or if unavailable, falls back to the default
95+ * (English) title & description (`field_talk_title` & `field_talk_description`).
96+ */
97+ function interledger_preprocess_node__summit_talk_2025__full(&$variables)
98+ {
99+ $node = \Drupal::routeMatch()->getParameter('node');
100+
101+ $variables['description'] = interledger_get_summit_entity_field($node, 'field_descripcion', 'field_talk_description');
102+ $variables['title'] = interledger_get_summit_entity_field($node, 'field_titulo_de_la_sesion', 'field_talk_title');
103+ }
104+
105+ /**
106+ * Preprocesses the Summit Talk 2025 teasers displayed in summit/2025/talks view
107+ *
108+ * Sets the Talk title and talk description based on the view language.
109+ *
110+ * Uses the Spanish title & description (`field_titulo_de_la_sesion` & `field_descripcion`) when viewing
111+ * the page in Spanish; otherwise, or if unavailable, falls back to the default
112+ * (English) title & description (`field_talk_title` & `field_talk_description`).
113+ */
114+ function interledger_preprocess_node__summit_talk_2025__teaser(&$variables)
115+ {
116+ $node = $variables['node'];
117+
118+ $variables['description'] = interledger_get_summit_entity_field($node, 'field_descripcion', 'field_talk_description');
119+ $variables['title'] = interledger_get_summit_entity_field($node, 'field_titulo_de_la_sesion', 'field_talk_title');
120+ }
121+
122+ /**
123+ * Preprocesses the `field--node-speaker-talk-entities` field
124+ * displayed on /summit/2025/speaker/[speaker-name] page
125+ *
126+ * Prepares data for Summit Talk teasers based on the view language nodes
127+ * Uses the Spanish title & description (`field_titulo_de_la_sesion` &
128+ * `field_descripcion`) when viewing the page in Spanish; otherwise,
129+ * or if unavailable, falls back to the default (English) title &
130+ * description (`field_talk_title` & `field_talk_description`).
131+ **/
132+ function interledger_preprocess_field__node__field_speaker_talk_entities(&$variables)
133+ {
134+ $items = $variables['items'];
135+
136+ foreach ($items as $index => $item) {
137+ $node = $item['content']['#node'];
138+ $template_index = $index + 1;
139+
140+ $variables['description'][$template_index] = interledger_get_summit_entity_field($node, 'field_descripcion', 'field_talk_description');
141+ $variables['title'][$template_index] = interledger_get_summit_entity_field($node, 'field_titulo_de_la_sesion', 'field_talk_title');
142+ }
143+ }
0 commit comments