Hi

I'm using Drupal 5.1 on Win2003 server with the Helicon ISAPI rewrite installed and working, clean URLs and the Path module enabled.

I'm using the following to get the path information in page.tlp.php:

$path = $node->path;

This works fine for me when I'm logged in to the site as an authenticated user. However, for non-authenticated users the $path variable is blank.

Am I missing something? Why would I get this behaviour?

Many thanks,

Ed

Comments

astra’s picture

I have the same problem about getting a node path when I try to theme a "List View".

I use this way below to 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 .

Anyone know how to get a node path variable that can work for both non-authenticated users and authenticated users?

mcantelon’s picture

I just looked at the code in Drupal 4.7 as I got bit by this problem. The $node->path property is explicitly NOT set unless you have certain privileges (which anonymous users do not). Why this is, I do not know.

-Mike Cantelon
http://mikecantelon.com

oeln’s picture

Identical problem: I need to obtain this path info in page.tpl.php, but it only works if I'm logged in.

Edit: I've gotten the following to work instead:

drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
drupal_init_path();
$path = drupal_lookup_path('alias', $_GET['q']);
oeln’s picture

Odd, but I think I've found that this works for pages I've created, but not for pages like the contact form: if I echo $path on /contact, it's empty, while if I were to echo $path on a page I'd created like /info it would print 'info'. I've not yet identified why this is..

kerrizor’s picture

function path_nodeapi(&$node, $op, $arg) {
  if (user_access('create url aliases') || user_access('administer url aliases')) {
...

fix being submitted to module owners

xentek’s picture

I fixed this by just giving anonymous users 'create url aliases' access permissions. This fixed it for me.

xentek’s picture

If you set 'admin url aliases' or 'create url aliases' privileges to anonymous users, you risk exposing controls to this module to unauthorized parties.

I have modified this module to fix this security issue, and would like to submit my code back to the community to be incorporated into the official module code.

Contact me with how I can submit my fixes.

More info here: http://drupal.org/handbook/modules/path