Is it correct to use the $language variable to make conditions in the page-front.tpl.php?
Is if ($language == 'es') correct?

1 Answer 1


The variables that are usable in a page template are visible in the source code of template_preprocess_page(). The template file you are referring to has the variable $language, which is a copy of the global $language, where $language->direction has instead the values "rtl" and "ltr."
The content of $language is an object with the following properties:

  • 'language'
  • 'name'
  • 'native'
  • 'direction'
  • 'enabled'
  • 'plurals'
  • 'formula'
  • 'domain'
  • 'prefix'
  • 'weight'
  • 'javascript'

The line of code you wrote needs to be written as if ($language->language == 'es').


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.