Thursday, August 25, 2011

To get the URL Alias of a node

To get the URL Alias of a node:

$system_path = 'node/'.arg(1);
$current_path = drupal_get_path_alias($system_path);
 
Using a Normal DB query, to get the node id form the node tabel like this,
$nid = db_result(db_query("SELECT nid FROM {term_node} 
WHERE tid = %d", $tid)); 
$system_path = 'node/'.$nid; 
$current_path = drupal_get_path_alias($system_path);
 
One more important information,if you opening a popup window,you are in 
need to get the base url of the page that you opens the pop up.Then you 
need to use this,
$basename = $_SERVER['HTTP_REFERER']; 
It will refer the base path of the page that you have opens the pop up.. 
 

No comments:

Post a Comment