1

Can a preprocess hook convert the default ul of hyperlinks into a drop-down select list? Something like this hook.

function THEME_preprocess_links__language_block(&$variables)
2

You can copy the core/modules/system/templates/links.html.twig into your theme's templates directory, call it links--language-block.html.twig and in this file adjust the output from the default ul/li structure into a different html structure.

NOTE: there is already 3 maybe more modules that convert the language switcher to dropdown lang_dropdown, dropdown_language and bootstrap_languages.

1
  • Thanks Glorgosk. I want to use the core language switcher because I had a pre process hook to hide languages if that language was not available on the node. But I ended up using the module Language Switcher Dropdown drupal.org/project/lang_dropdown/releases/8.x-2.0-beta3. And the was a patch available for it that would hide languages. – paulcap1 Jun 14 '18 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.