0

I am trying to get to grips with D8, and want to be able to use the language module's language switcher block. I am trying to alter the output to get it to display as a select element rather than a list.I tried creating block--languageswitcher.html.twig but couldn't see how to alter the list.

Looking into the module, I can see a function language_element_info_alter but cannot see how to use this to render a different output.

Do I need to use a block_alter or theme hook? In the LanguageBlock.php, the build() function returns an array with a #theme parameter set to links__language_block. Would this be what I need?

  • You could create own language block. – ya.teck Nov 15 '16 at 17:14
  • @ya.teck I will probably do so, even if it's just a learning exercise. I'd still like to be able to override the output of the existing module. – Alex Holsgrove Nov 15 '16 at 17:31
1

Yes, you could override the links__language_block template (links--language-block.html.twig) and print out a select there by hand. You would also need JS to make selecting something the same as clicking a link as an option element alone won't be able to trigger like a form.

| improve this answer | |

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.