I'm not sure if this question is phrased correctly; I'm happy to accept any solution that accomplishes my aim.

GOAL: I am trying to print the language switcher block in the header of my theme without the block-related classes, because the theming for these classes assumes that the block will be printed in the main content area of the page.

Usually, I've been adding the language switcher block as a widget using the Panels module. When I do this, no block-related classes are printed, and it's much easier to style the CSS. However, I can't add the widget in the header because I'm not using Panels Everywhere and Panels only overrides the main content area of the page.

I looked in locale.module and tried calling the block directly via local_block_view(), but this still adds the CSS classes that I don't want.

Is there a way to print the block without the block classes? Or, barring that, how can I remove the classes for this specific block?

1 Answer 1


Digging locale_block_view() out of locale.module:

 * Implements hook_block_view().
 * Displays a language switcher. Only show if we have at least two languages.
function locale_block_view($type) {
  if (drupal_multilingual()) {
    $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
    $links = language_negotiation_get_switch_links($type, $path);

    if (isset($links->links)) {
      drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
      $class = "language-switcher-{$links->provider}";
      $variables = array('links' => $links->links, 'attributes' => array('class' => array($class)));
      $block['content'] = theme('links__locale_block', $variables);
      $block['subject'] = t('Languages');
      return $block;

shows that it is "just" theming up some links. So, you have a couple options here that may work depending on what exact divs/CSS you want/don't want:

  1. Override theme_links() to use "links__local_block" and wrap it in some divs that you can apply CSS to.
  2. Stuff all the guts above in a custom module's block_view() so you can override its block CSS.
  3. Add different or additional classes to the $variables[class'] array,
  4. Include, or override in your theme, a different locale.css file,
  5. Override the block.tpl.php for this specific block, eg, block--locale.tpl.php (see: http://drupal.org/node/1089656) (copy it out of .../modules/block/block.tpl.php and into your theme and change the classes)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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