Last active
January 15, 2019 14:23
-
-
Save vkechagias/c0fe26cceb8c807a307fb7693c8450aa to your computer and use it in GitHub Desktop.
Drupal 8: Proper way to consistently get field entity according to active language in themename.theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function THEME_preprocess_page__node(&$variables) { | |
$translated_node = \Drupal::service('entity.repository')->getTranslationFromContext($variables['node']); | |
if (!empty($translated_node)) { | |
$field_data = $translated_node->get('FIELD_MACHINE_NAME')->getValue(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment