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>
I believe you can use the $user variable in template.php. global $user; debug($user); -or, if using Drupal 6- dsm($user); http://api.drupal.org/api/drupal/developer--globals.php/global/user/7 Regards, Todd On 25 Aug 2011, at 06:34, 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 - Facebook - Website
I used global $language; $user is the one which user select for default language in profile I guess On Thu, Aug 25, 2011 at 3:50 PM, Todd <todd@savagevenus.net> wrote:
I believe you can use the $user variable in template.php.
global $user; debug($user); -or, if using Drupal 6- dsm($user);
http://api.drupal.org/api/drupal/developer--globals.php/global/user/7
Regards, Todd
On 25 Aug 2011, at 06:34, 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/>
-- Pooya Sanooei Twitter <http://twitter.com/sourcesoft> - Facebook<http://facebook.com/pooya.sanooei>- Website <http://www.sanooei.com>
Also remember that "arg(0)" sees the real path, not a URL alias. If "news" is an alias of "node/123" then arg(0) will be "node." If you want to see the alias, then you need to check "$_GET['q']". Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
________________________________ From: Pooya <pooya.source@gmail.com> To: development@drupal.org Sent: Thursday, August 25, 2011 8:00 AM Subject: Re: [development] active language in template.php
I used global $language;
$user is the one which user select for default language in profile I guess
On Thu, Aug 25, 2011 at 3:50 PM, Todd <todd@savagevenus.net> wrote:
I believe you can use the $user variable in template.php.
global $user; debug($user); -or, if using Drupal 6- dsm($user);
http://api.drupal.org/api/drupal/developer--globals.php/global/user/7
Regards, Todd
On 25 Aug 2011, at 06:34, 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 - Facebook - Website
--
Pooya Sanooei
Twitter - Facebook - Website
It did work using arg(0)=='news' cause news is a views which list the last story type. I guess views page name is the real path :) On Thu, Aug 25, 2011 at 4:43 PM, Ms. Nancy Wichmann <nan_wich@bellsouth.net>wrote:
Also remember that "arg(0)" sees the real path, not a URL alias. If "news" is an alias of "node/123" then arg(0) will be "node." If you want to see the alias, then you need to check "$_GET['q']". *Nancy*
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
------------------------------ *From:* Pooya <pooya.source@gmail.com> *To:* development@drupal.org *Sent:* Thursday, August 25, 2011 8:00 AM *Subject:* Re: [development] active language in template.php
I used global $language; $user is the one which user select for default language in profile I guess
On Thu, Aug 25, 2011 at 3:50 PM, Todd <todd@savagevenus.net> wrote:
I believe you can use the $user variable in template.php.
global $user; debug($user); -or, if using Drupal 6- dsm($user);
http://api.drupal.org/api/drupal/developer--globals.php/global/user/7
Regards, Todd
On 25 Aug 2011, at 06:34, 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/>
-- Pooya Sanooei Twitter <http://twitter.com/sourcesoft> - Facebook<http://facebook.com/pooya.sanooei>- Website <http://www.sanooei.com>
-- Pooya Sanooei Twitter <http://twitter.com/sourcesoft> - Facebook<http://facebook.com/pooya.sanooei>- Website <http://www.sanooei.com>
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>
participants (4)
-
Christoph Burschka -
Ms. Nancy Wichmann -
Pooya -
Todd