diff --git a/hdbt.theme b/hdbt.theme index 02361f0d3..84472d8f6 100644 --- a/hdbt.theme +++ b/hdbt.theme @@ -1840,40 +1840,6 @@ function hdbt_preprocess_paragraph__job_search(array &$variables) { } } -/** - * Implements hook_preprocess_HOOK(). - */ -function hdbt_preprocess_external_entity__helfi_hearings(array &$variables) { - $language = \Drupal::languageManager() - ->getCurrentLanguage(LanguageInterface::TYPE_CONTENT) - ->getId(); - $entity = $variables['external_entity']; - $hearingLangcode = $entity->get('langcode')->value; - if ($hearingLangcode && $hearingLangcode == $language) { - return; - } - $existingLanguages = explode(',', $entity->get('existing_translations')->value); - - if (in_array("fi", $existingLanguages) && in_array("en", $existingLanguages) && count($existingLanguages) === 2) { - $variables['available_in_languages'] = t('Hearing only available in Finnish and English', [], ['context' => 'Hearing available in languages']); - } - if (in_array("fi", $existingLanguages) && in_array("sv", $existingLanguages) && count($existingLanguages) === 2) { - $variables['available_in_languages'] = t('Hearing only available in Finnish and Swedish', [], ['context' => 'Hearing available in languages']); - } - if (in_array("en", $existingLanguages) && in_array("sv", $existingLanguages) && count($existingLanguages) === 2) { - $variables['available_in_languages'] = t('Hearing only available in English and Swedish', [], ['context' => 'Hearing available in languages']); - } - if (in_array("fi", $existingLanguages) && count($existingLanguages) === 1) { - $variables['available_in_languages'] = t('Hearing only available in Finnish', [], ['context' => 'Hearing available in languages']); - } - if (in_array("en", $existingLanguages) && count($existingLanguages) === 1) { - $variables['available_in_languages'] = t('Hearing only available in English', [], ['context' => 'Hearing available in languages']); - } - if (in_array("sv", $existingLanguages) && count($existingLanguages) === 1) { - $variables['available_in_languages'] = t('Hearing only available in Swedish', [], ['context' => 'Hearing available in languages']); - } -} - /** * Implements hook_theme_suggestions_alter() for container. */ diff --git a/templates/content/external-entity--helfi-hearings.html.twig b/templates/content/external-entity--helfi-hearings.html.twig index 485392c51..3f811f11f 100644 --- a/templates/content/external-entity--helfi-hearings.html.twig +++ b/templates/content/external-entity--helfi-hearings.html.twig @@ -18,63 +18,28 @@ {% set card_unpublished_on = '-' %} {% endif %} -{% if available_in_languages %} - {% embed '@hdbt/component/card.twig' with { - card_modifier_class: card_hearing_classes|join(' '), - card_title: content.title[0]['#context'].value, - card_title_lang: content.langcode[0]['#context'].value, - card_image: content.main_image, - card_url: content.url[0]['#context'].value, - card_url_external: true, - card_metas: [ - { - icon: 'clock', - label: 'Opened'|t({}, {'context': 'Label for hearing opened date'}), - content: card_published_on, - }, - { - icon: 'clock', - label: 'Closes'|t({}, {'context': 'Label for hearing closes date'}), - content: card_unpublished_on, - }, - { - icon: 'speechbubble-text', - label: 'Activity'|t({}, {'context': 'Label for hearing activity row'}), - content: card_hearing_comments, - }, - ], - card_tags: [ - { - tag: available_in_languages, - color: 'alert', - } - ], - } %} - {% endembed %} -{% else %} - {% embed '@hdbt/component/card.twig' with { - card_modifier_class: card_hearing_classes|join(' '), - card_title: content.title[0]['#context'].value, - card_image: content.main_image, - card_url: content.url[0]['#context'].value, - card_url_external: true, - card_metas: [ - { - icon: 'clock', - label: 'Opened'|t({}, {'context': 'Label for hearing opened date'}), - content: card_published_on, - }, - { - icon: 'clock', - label: 'Closes'|t({}, {'context': 'Label for hearing closes date'}), - content: card_unpublished_on, - }, - { - icon: 'speechbubble-text', - label: 'Activity'|t({}, {'context': 'Label for hearing activity row'}), - content: card_hearing_comments, - }, - ] - } %} - {% endembed %} -{% endif %} +{% embed '@hdbt/component/card.twig' with { + card_modifier_class: card_hearing_classes|join(' '), + card_title: content.title[0]['#context'].value, + card_image: content.main_image, + card_url: content.url[0]['#context'].value, + card_url_external: true, + card_metas: [ + { + icon: 'clock', + label: 'Opened'|t({}, {'context': 'Label for hearing opened date'}), + content: card_published_on, + }, + { + icon: 'clock', + label: 'Closes'|t({}, {'context': 'Label for hearing closes date'}), + content: card_unpublished_on, + }, + { + icon: 'speechbubble-text', + label: 'Activity'|t({}, {'context': 'Label for hearing activity row'}), + content: card_hearing_comments, + }, + ] +} %} +{% endembed %}