Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The language switcher block is very much like a flat menu, but its HTML is rendered differently to other menu blocks, thus creating extra difficulty with theming.
In a block which renders a flat menu, the
- tag should be given the CSS class "menu", and all the
- tags should be given the class "leaf". It appears this is not done with the language switcher block.
Temporary workaround is to create a custom block.tpl.php with the following inserted at the beginning:
if ($block->module == 'locale') {
// standard block rendering doesn't include these classes
$block->content = str_replace('- ', '
Comments
Comment #1
linuxxguy CreditAttribution: linuxxguy commentedOops... forgot that <ul> and <li> are not encoded in the post. Coffee not had taken effect, should have previewed, duh. OK, it should be:
In a block which renders a flat menu, the <ul> tag should be given the CSS class "menu", and all the <li> tags should be given the class "leaf". It appears this is not done with the language switcher block.
...
if ($block->module == 'locale') {
// standard block rendering doesn't include these classes
$block->content = str_replace('<ul>', '<ul class="menu">',
str_replace('<li class="', '<li class="leaf ', $block->content)
);
}