Does anybody know the code for telling you what page you are in?

Comments

cog.rusty’s picture

One way is the arg() function.

http://api.drupal.org/api/function/arg/6

if (arg(0) == 'node' && ctype_digit(arg(1))) {  // if the path is /node/some_number
  // ...do something...
}

If you have aliased paths, arg() still uses the original drupal path. So, depending what you want to do, in some cases you may need to combine it with drupal_get_normal_path(), or the opposite, use drupal_get_path_alias() and split it yourself.

http://api.drupal.org/api/function/drupal_get_normal_path/6
http://api.drupal.org/api/function/drupal_get_path_alias/6

nifelseki’s picture

Thanks. This one works well.. I have also looked at the Virtual Sites module which is also nice.. ;)

phpsharma’s picture

 $isargs=$_REQUEST['q'];
 $argsArray= explode("/",$isargs);
print_r($argsArray);

put this where ever you want on top of the page.? $argsArray Is an array cutting the URL?

Please let me know if it works.?

sharma

nifelseki’s picture

I tried this on my block tpl's and I only got Array ( [0] => ).. ;)

phpsharma’s picture

if you path is http://drupal.org/handbooks

the array will be

Array ( [0] =>handbooks ).

try it in a block once..

sharma chelluri

cog.rusty’s picture

I think that depending on the context where you are using it, the variable $_REQUEST may need to be declared as global $_REQUEST; first. But I may be wrong about that.

phpsharma’s picture

Put this in geiric block not in any tpls for now.

sharma chelluri