function mcah_theme_preprocess_node(&$variables) { $node = $variables['node']; \Drupal::logger('mcah_theme')->debug('Preprocess function called for node ID: ' . $variables['node']->id()); if ($node->hasField('field_alw_complete') && $node->field_alw_complete->value) { // Change the view mode conditionally $variables['view_mode'] = 'alw'; } else { $variables['view_mode'] = 'default'; } }