8

Normally I would use $language to get the active language on my drupal 7 page. Now I'm doing some changes to a node content (set to PHP code) and I can't seem to get any variables working? I badly need to get the active language inside the node content - how?

10

If I understand your question:

global $language_content;

This will return a language object with the current language.

|improve this answer|||||
  • It works! Thank you. I wonder why it was so hard to find this variable. – user1855 Jul 5 '11 at 12:57
  • 4
  • @corbacho: I already had looked at the docs but misunderstood the difference between $language and $language_content. It seems clear to me now. Thanks. – user1855 Jul 5 '11 at 13:32
3

It also works within a block. I created a PHP block where I wanted to customize a link with the language variable, and placed this code inside:

<?php global $language_content; print $language_content->language; ?>

Thank you for sharing!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy