Re: active language in template.php
Christoph Burschka <[email protected]>
| Newsgroups | gmane.comp.php.drupal.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
$language is a global variable; you need to import it into the function
scope with "global $language" to access it.
I'm not entirely sure what you're trying to accomplish, but maybe 'Home'
and 'News' should be passed through the t() function, so that they can
be localised to the active language automatically?
Regards,
Christoph
On 08/25/2011 12:34 PM, Pooya wrote:
> Quick and simple:
> is there a way to get the active language user is viewing site in
> template.php, sth like $language->language in page.tpl.php?
>
> I want to use it in a condition like this:
> function rouzdarou_breadcrumb($breadcrumb) {
>
> if(arg(0) == 'news'){
> global $base_url;
> if($language->language=='en'):
> $breadcrumb[0] = l('Home', $base_url);
> $breadcrumb[1] = l('News', 'news');
> endif;
> }
> return theme_breadcrumb($breadcrumb);
> }
>
>
> but dsm($language->language); returns nothing in template.php. If any1
> knows another way to achieve this share :)
> Thanks in advanced.
>
> --
> Pooya Sanooei
> Twitter <http://twitter.com/sourcesoft> - Facebook
> <http://facebook.com/pooya.sanooei> - Website <http://www.sanooei.com>
>
signature.asc
(application/pgp-signature, 262 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk5WN5gACgkQhbef5VWlKioPJgCghITeZQqiq3AQJG3eZTaKxq+I UsAAoLBIskUgx/nErrD9XGmjuDEoY4JE =goZN -----END PGP SIGNATURE-----