Hi,

I'm trying to get the current page's url in page.tpl.php for all pages (nodes, taxanomy, ..)
I used this

print drupal_lookup_path('alias',"node/".$node->nid);

but it give a php error if the current page is not a node.

Notice : Undefined variable: node

Could you tell me another way to get the current path ?

Comments

ayesh’s picture

Unless you load, $node is only available to node.tpl.php
Use this to get the URL.
print url($_GET['q']);
Works in both D6 and D7. See api.drupal.org 's url() function's docs for absolute link (http://example.com/node/4 like URLs. Default is node/4. If an alias is found, it will be used).

arh1’s picture

Also check out Drupal's arg function.