Hi,
The PHP code in the template only works when I am logged in as the administrator. It's not available to the users.
I am trying to embed a flash file from a directory and I have the following code to do it:
// Remove the - from the title
$gtitle = preg_replace('/-/', "", $node->path);
// Create the path to the flash file
// Path = games/title/title.swf
$gpath = "games/".$gtitle."/".$gtitle.".swf";
// Creat path to the gif file to use for icon.
$gicon = "games/".$gtitle."/".$gtitle.".gif";
$node->picture = $gicon;
print $node->picture;
print "\n";
It's rather basic but the variables like $node->path are only defined when I am logged in as admin. I tried printing all the variables out and only $node->vid seems to be always defined. The rest ONLY get defined when user1 is logged in. How can I work around this issue?
You can see the issue and the DEBUG messages I printed here: http://jokenuts.com/drupal/
Just search for the word DEBUG on the page.
Please advise.
Thanks,
-Arman
Comments
Comment #1
alxbkh commentedpath module works only with admin permissions, use $node->nid instead... or $node->title maybe
Comment #2
jamiers commentedIs this by design? I posted this question in the pathauto and they said it wasn't a problem with pathauto. It seems silly to use the $node->path if it isn't available to anonymous users. This is the information that I posted at pathauto:
My stories currently use relative links (../subscribe or ../go/link). When I use the "node" method, those links get botched up. There isn't any way around the $path->node being only available to users logged in?
Thanks for your help.
Jamie
Comment #3
aohanian commentedHi Jamie,
I used $path->title for my purpose. It isn't the best solution, but it works for the time being.
I used it to load the games from a predefined location. It doesn't work for all the games because "title" and "path" variables are not always the same.
If you like to check it out, here is my site http://www.jokenuts.com/drupal/ ( still under construction).
Scroll down for the games. I used the $node->title to derive the icon locations from the contemplates.
Good luck.
-Arman.
Comment #4
blb commentedi agree that this is not the way it should work - seems like a bug.
the workaround that i used is this:
that worked for me.
Comment #5
jjeff commentedThis is not a bug with anything per se. However, the permission for this code is being generated on line 214 here:
http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/path/path.module?a...
For some reason path module only adds this information for users with administration access.
It depends on your use case, but either
url('node/'. $node->nid)ordrupal_get_path_alias('node/'. $node->nid)are what you want...Comment #6
liquidcms commentedyup, just stumbled upon this same issue.. very odd.. and i would say it is certainly a bug..unless someone can explain a good reason why path alias should be usable in tpls ???
Comment #7
markosef commentedYes i agree with all. Path would be used for nicer URLS that would be SEO friendly and i don't think SE like to login to drupal and than do their search :-)
Many ppl like me would try to use something like
print "<a href=\"".$node->path."\">".$node->links['node_read_more']['title']."</a>";but that works only when logged in, so correct way or WA is
print "<a href=\"".drupal_get_path_alias('node/'.$node->nid)."\">".$node->links['node_read_more']['title']."</a>";gives same result as the one when logged (thanx blb)
Comment #8
summit commentedSubscribing, greetings, Martijn
Comment #9
maxiorelsubscribing
Comment #10
UnicornSong commentedSubscribing..
I have this issue. the template is not used at all when not logged in.
I added a template to merely try to overcome weirdness in the content type's field order.
Which works fine for administrator, we now see the price div as the last div.
But when an anonymous user views the page the html structure is so: