Community Documentation

Show or Hide Blocks Based on Current Active or Selected Language

Last updated June 2, 2009. Created by wOOge on June 2, 2009.
Log in to edit this page.

Show or hide blocks based on the current active or selected language by following these simple steps. This assumes you know Drupal basics, and have basic PHP knowledge (or can at least wing it).

- Create or Edit a block
- Under Visibility settings change to PHP
(If PHP is not an option, go into modules and enable the PHP input method)
- Use this for your PHP code:

<?php
global $language;
$lang_name = $language->language;
if (
$lang_name == "en" ) { return TRUE; } else { return FALSE; }
?>

- Save your block.

*NOTE* Replace the "en" with the two letter name of what ever language you want the block to be visible for. For Example if you want your block only visible when the language is French, change "en" to "fr" .

Based on code from: http://drupal.org/node/277675

About this page

Drupal version
Drupal 6.x
Audience
Documentation contributors

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here