Find URL alias for a node

Description

Use this snippet to find the URL alias for a node by looking it up in the url_alias table by its node ID.

Snippet

$src = 'node/'.$node->nid;
$path = db_result(db_query("SELECT dst FROM url_alias WHERE src = '%s'",$src));

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Links to specified hosts will have a rel="nofollow" added to them.

More information about formatting options