Hi,

I have the pathauto module installed.

Given a node's nid, how do I get the path? I don't really want to use /node/$nid, I want to use the pathauto path. But can't work out how.

Please help,

Thanks,

Jon.

Comments

agentrickard’s picture

http://api.drupal.org/api/5/function/drupal_get_path_alias

drupal_get_path_alias($path)

In this case, $path = 'node/' . $node->nid

--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.

nevets’s picture

If you are trying to produce a link, it is good to use the l() function (that's a lower case L) to produce a link. In its simplist form it looks like

$link = l($title, $path);

If you pass it a path like node/3 that has an alias it will handle returning the link to the alias. It also handles clean URLs being on or off which is another benefit (it is more portable that hand coding the link)

agentrickard’s picture

nevets answer may be more accurate for what you're trying to do. But you didn't say what you were trying to do.

l() automatically calls drupal_get_path_alias()

--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.

fcmisc’s picture

Thanks for the help guys. That's let me do exactly what I wanted.

happy coding,

fcmisc.