From de93ba795a0d45ccdc21acb35029d77d8b119312 Mon Sep 17 00:00:00 2001 From: escuriola <escuriola@gmail.com> Date: Tue, 26 Oct 2021 12:21:19 +0200 Subject: [PATCH] OEL-579: Add EC/EU theme variable and use it to display EU/EC corporate blocks. --- oe_whitelabel.theme | 23 +++++++++++++++++++ templates/overrides/page/page.html.twig | 2 +- .../header_nav/pattern-header_nav.html.twig | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/oe_whitelabel.theme b/oe_whitelabel.theme index 11537821..230dbc93 100644 --- a/oe_whitelabel.theme +++ b/oe_whitelabel.theme @@ -91,3 +91,26 @@ function oe_whitelabel_form_facets_form_alter(&$form, FormStateInterface $form_s } } } + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function oe_whitelabel_form_system_theme_settings_alter(&$form, FormStateInterface &$form_state, $form_id = NULL) { + $form['component_library'] = [ + '#type' => 'select', + '#title' => t('Component library'), + '#options' => [ + 'ec' => t('European Commission'), + 'eu' => t('European Union'), + ], + '#default_value' => theme_get_setting('component_library'), + '#description' => t('Choose "European Commission" for websites hosted under the ec.europa.eu domain and "European Union" for websites hosted under the europa.eu domain.'), + ]; +} + +/** + * Implements hook_preprocess(). + */ +function oe_whitelabel_preprocess(&$variables) { + $variables['bcl_component_library'] = theme_get_setting('component_library'); +} diff --git a/templates/overrides/page/page.html.twig b/templates/overrides/page/page.html.twig index 12586322..19b050ef 100644 --- a/templates/overrides/page/page.html.twig +++ b/templates/overrides/page/page.html.twig @@ -97,7 +97,7 @@ </main> {% if page.footer %} - {% if "ecfooterblock" in page.footer|keys %} + {% if bcl_component_library == 'ec' %} <footer class="ec__footer bcl-footer mt-4"> {% else %} <footer class="bcl-footer mt-4"> diff --git a/templates/patterns/header_nav/pattern-header_nav.html.twig b/templates/patterns/header_nav/pattern-header_nav.html.twig index 7de0c89c..40c011f4 100644 --- a/templates/patterns/header_nav/pattern-header_nav.html.twig +++ b/templates/patterns/header_nav/pattern-header_nav.html.twig @@ -1,4 +1,4 @@ -{% if 'corporateeclogoblock' in navbar_branding|keys %} +{% if bcl_component_library == 'ec' %} <header class="ec__header bcl-header"> {% else %} <header class="bcl-header"> -- GitLab