By neet_khuranas on
here m trying to give links..also using pathauto and url_aliases but getting warnings indeed..
how should i use node_url to gat path ?
any help is appreciated..thanks
<? $restaurant=" SELECT node.title, node.nid,node.uid,node.created
FROM node
LEFT JOIN userreview ON node.nid = userreview.content_id
LEFT JOIN votingapi_vote ON votingapi_vote.vote_id = userreview.vote_id
WHERE node.type = 'restaurant'
ORDER BY votingapi_vote.timestamp DESC
LIMIT 0 , 5 ";
$result=mysql_query($restaurant) or die('prb');
?>
<table width='500'>
<? echo "<tr><td><b>Restaurants</b></td></tr>"?>
<?while($row=mysql_fetch_array($result))
{
$nid=$row->nid;
$data = node_load($nid);
?>
<tr><td>
<a href="<?php print l($data->title, "node/$data->nid"); ?>"><?echo $row[title];?></a>
</td></tr>
<?} ?>
</table>
Comments
drupal_get_path_alias
If I'm understanding what you're asking for correctly, you want the links in your table cells to link to the path alias instead of /node/nid.
To fetch the path alias for any node, you should use drupal_get_path_alias() (http://api.drupal.org/api/function/drupal_get_path_alias/5).
You also have another problem in that you're using l() inside of an href attribute in an anchor which is going to give you very messed up code. l() returns a fully formatted anchor.
your code should look something like this:
--
B. McMurray
--
Brian McMurray
thanks
Hi McMurray
yes..it worked..thanks a lot..