By Jurgen8en on
print $node->path prints the right url in IE, but in Firefox it is empty.
Anyone know, what can be the problem.
It happens in the teaser of the product-contenttype of Ubercart
The hole code
<div class="product product-dummy">
<div class="product-body">
<div class="field product-image field-field-image-cache">
<div class="product_image"><a href="<?php print $node->field_image_cache[0]['filepath'] ?>" class="thickbox" rel="field_image_cache"><img src="/files/imagecache/product/<?php print $node->field_image_cache[0]['filepath'] ?>" alt="" title="" /></a>
</div>
</div>
<div class="field product-content field-type-text"><a href="/nl/<?php print $node->path ?>">
<b><?php print $node->title ?></b></a>
<?php print substr($node->content['body']['#value'],0,200) ?> ...<br />
<a href="/nl/<?php print $node->path ?>">Meer info</a>
</div>
</div>
<div class="field product-price field-type-arithmic"><b><span class="list-price"><?php print $node->list_price ?></span><br />
<div class="sell-price">€ <?php print $node->sell_price ?>
</div></b>
</div>
<div class="field product-bestel field-type-button"><?php print $node->content['add_to_cart']['#value'] ?>
</div>
</div><br />
Comments
Read something about privileges
The $node->path property is explicitly NOT set unless you have certain privileges (which anonymous users do not).
Which privileges, suggestions?
Maybe here is the problem, but why the difference then between IE and Firefox?
...
Yes. He's probably logged in in his IE (as admin), but surfing as anonymous in Firefox.
The code says:
Thanks, I also read this on
Thanks, I also read this on this forum. "There's only one reason why 'path' is loaded onto the node object: for use in the node editing page. If the user is not allowed to edit the path, as is the case for anonymous users (and others not having the proper permission), there's no reason to load this field."
But then, how can i get the nodepath in the contemplate? For every user.
Or must I change the function (where is it located?)?
...
Do
drupal_get_path_alias("node/$node->nid");easy, thanks
easy, thanks.
Doesn't work
This doesn't work due to unset $node->nid variable for unauthorized (not logged).
Unauthorized user is unable to get node path using this way.
Without patching of the path module you have to add any of '... url aliases' priviledge.
However unauthorized user has no access to administration menu and powerful api functions
(e.g. cannot user PHP code), such extra priviledges seems to be unpredictible danger
for whole Drupal system.
The solution is described in topic: http://drupal.org/node/66642.
Just apply patch described in update post.
There is only one crucial question: why 'load' has to be depended on any url manipulating priviledge?!?
For all public (authorized or not) all urls existing in Drupal should be accessibe without any limitations
unless some special restrictions will be apllied to selected paths or subtrees if such 'path access control'
module will be loaded and activated (is there such module yet?).
reversed