How to get a node path when I try to theme a "List View".

I'm using the following code get node path in views-list-myview.tpl.php

$n = node_load($node->nid);
$path = $n->path;

This works when logged in to my site as an authenticated user. But the $path variable is blank for non-authenticated users .

How to get a node path variable that can work for both non-authenticated users and authenticated users? Thanks!

Comments

kuldip zala’s picture

first
$node = node_load($nid)
then
$path = drupal_get_path_alias('node/'.$node->nid);

OR

$path = drupal_get_path_alias('node/'.$nid);

merlinofchaos’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.