Language switcher footer
This commit is contained in:
parent
7184d9cfc3
commit
be9d0e8083
6 changed files with 62 additions and 19 deletions
|
@ -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",
|
||||
|
|
27
config/sync/block.block.languageswitcher.yml
Normal file
27
config/sync/block.block.languageswitcher.yml
Normal file
|
@ -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: { }
|
|
@ -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
|
|
@ -40,6 +40,7 @@ module:
|
|||
dblog: 0
|
||||
default_content: 0
|
||||
diff: 0
|
||||
dropdown_language: 0
|
||||
drutopia_action: 0
|
||||
drutopia_article: 0
|
||||
drutopia_blog: 0
|
||||
|
|
6
config/sync/dropdown_language.setting.yml
Normal file
6
config/sync/dropdown_language.setting.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
wrapper: false
|
||||
display_language_id: 2
|
||||
filter_untranslated: 0
|
||||
always_show_block: 0
|
||||
_core:
|
||||
default_config_hash: xbqiqGnFfv7G00sewxA46T8PO-uo8uvWhDSIFyR1Fhk
|
|
@ -1,25 +1,14 @@
|
|||
<?php
|
||||
|
||||
use \Drupal\Core\Url;
|
||||
use \Drupal\block\Entity\Block;
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_block__system_menu_block__main().
|
||||
* Implements hook_preprocess_region__footer().
|
||||
*/
|
||||
function agarica_preprocess_block__system_menu_block__main(&$variables) {
|
||||
$pathMatcher = \Drupal::service('path.matcher');
|
||||
$languageManager = \Drupal::service('language_manager');
|
||||
$route_name = $pathMatcher->isFrontPage() ? '<front>' : '<current>';
|
||||
$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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue