Posts Tagged 'path'

Get alias or system path: drupal_lookup_path

l function converts automatically system path in alias where available.

This simple snippet ports this useful function on your raw HTML attributes, point to alias or to the system path.

if(($nodepath = drupal_lookup_path('alias',"node/".$realnode->nid))===FALSE)
$nodepath =  base_path() . "node/".$realnode->nid;

Where $nodepath can be used on href

Cfr. drupal_lookup_path

Contemplate and views: create a link without $node->path

In contemplate and views, $node->path return current page path. But this variable is only available to users with “administer alias” permission, so as administrator you can view links, but as normal user you cannot use them.

Here a $node->path alternative:

l(strip_tags($node->title),"node/".$node->nid)

Since $node->title is raw input, strip_tags strips all HTML tags.
A node/$node->nid links to article. Drupal link function returns the (in case) aliased path.


IE6: Rust in Peace

Blog Stats

  • 101,154 hits
My Bookshelf

Texts double licensed under Creative Commons Attribution - Share Alike license and GNU Free Documentation License. Examples may contain software licensed under GNU General Public License. Images and comments texts aren't necessarily licensed under these terms.