From be9d0e8083bd9155e889a703365310f2032ed6d2 Mon Sep 17 00:00:00 2001 From: David Valdez Date: Mon, 21 Jan 2019 23:48:06 -0600 Subject: [PATCH] Language switcher footer --- composer.json | 1 + config/sync/block.block.languageswitcher.yml | 27 +++++++++++++++++++ ...t.config_sync.module.dropdown_language.yml | 19 +++++++++++++ config/sync/core.extension.yml | 1 + config/sync/dropdown_language.setting.yml | 6 +++++ web/themes/custom/agarica/agarica.theme | 27 ++++++------------- 6 files changed, 62 insertions(+), 19 deletions(-) create mode 100644 config/sync/block.block.languageswitcher.yml create mode 100644 config/sync/config_snapshot.snapshot.config_sync.module.dropdown_language.yml create mode 100644 config/sync/dropdown_language.setting.yml diff --git a/composer.json b/composer.json index 5a8af4f..21ebe06 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "drupal/core": "^8.6.2", "drupal/customerror": "1.x-dev", "drupal/diff": "^1.0@RC", + "drupal/dropdown_language": "^2.2", "drupal/drutopia_core": "1.x-dev", "drupal/google_analytics": "^2.3", "drupal/honeypot": "^1.29", diff --git a/config/sync/block.block.languageswitcher.yml b/config/sync/block.block.languageswitcher.yml new file mode 100644 index 0000000..0826509 --- /dev/null +++ b/config/sync/block.block.languageswitcher.yml @@ -0,0 +1,27 @@ +uuid: cddd6272-7a22-4110-862c-338686afc1c1 +langcode: en +status: true +dependencies: + module: + - block_visibility_groups + - dropdown_language + theme: + - agarica +id: languageswitcher +theme: agarica +region: footer +weight: 0 +provider: null +plugin: 'dropdown_language:language_interface' +settings: + id: 'dropdown_language:language_interface' + label: 'Language:' + provider: dropdown_language + label_display: visible + labels: null +visibility: + condition_group: + id: condition_group + negate: false + block_visibility_group: '' + context_mapping: { } diff --git a/config/sync/config_snapshot.snapshot.config_sync.module.dropdown_language.yml b/config/sync/config_snapshot.snapshot.config_sync.module.dropdown_language.yml new file mode 100644 index 0000000..47f9bb1 --- /dev/null +++ b/config/sync/config_snapshot.snapshot.config_sync.module.dropdown_language.yml @@ -0,0 +1,19 @@ +uuid: 1a7bd96c-ab4a-4a86-a541-b9610491c292 +langcode: en +status: true +dependencies: + module: + - dropdown_language +id: config_sync.module.dropdown_language +snapshotSet: config_sync +extensionType: module +extensionName: dropdown_language +items: + - + collection: '' + name: dropdown_language.setting + data: + wrapper: true + display_language_id: 0 + filter_untranslated: 0 + always_show_block: 0 diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index 26bb499..1846bba 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -40,6 +40,7 @@ module: dblog: 0 default_content: 0 diff: 0 + dropdown_language: 0 drutopia_action: 0 drutopia_article: 0 drutopia_blog: 0 diff --git a/config/sync/dropdown_language.setting.yml b/config/sync/dropdown_language.setting.yml new file mode 100644 index 0000000..dcc8658 --- /dev/null +++ b/config/sync/dropdown_language.setting.yml @@ -0,0 +1,6 @@ +wrapper: false +display_language_id: 2 +filter_untranslated: 0 +always_show_block: 0 +_core: + default_config_hash: xbqiqGnFfv7G00sewxA46T8PO-uo8uvWhDSIFyR1Fhk diff --git a/web/themes/custom/agarica/agarica.theme b/web/themes/custom/agarica/agarica.theme index 7d67d6e..210e044 100644 --- a/web/themes/custom/agarica/agarica.theme +++ b/web/themes/custom/agarica/agarica.theme @@ -1,25 +1,14 @@ isFrontPage() ? '' : ''; - $type = 'language_interface'; - $language_links = $languageManager->getLanguageSwitchLinks($type, Url::fromRoute($route_name)); - $variables['language'] = []; - foreach ($language_links->links as $langcode => $link) { - $language_links->links[$langcode]['attributes']['class'][] = 'navbar-item'; - $language_links->links[$langcode]['title'] = $langcode; - } - $variables['language'] = [ - '#theme' => 'links__language_block', - '#links' => $language_links->links, - '#set_active_class' => TRUE, - ]; - +function agarica_preprocess_region__footer(&$variables) { + $block = Block::load('languageswitcher'); + $block_content = \Drupal::entityTypeManager() + ->getViewBuilder('block') + ->view($block); + $variables['language_switcher'] = $block_content; }