I have created a CCK content type that contains a field defined as a node reference. The value in this field is available to logged in users but not to anonymous users. I'm defining a variable thus:
$coupon = $node->field_coupon[0][view];
then later testing for a value, thus:
<?php if ($coupon): ?> <div id="coupon" class="field field-type-nodereference field-field-coupon"> <?php print "Print ". $node->field_coupon[0][view] . " for " . $node->field_coupon_terms[0][value]; ?></div> <?php endif; ?>
$coupon has a value for logged in users but not for anonymous users. I do have the nid value available ($node->field_coupon[0][nid]) so it is possible to select the referred to node by selecting from the database but I'd rather not if I don't have to.
Thanks, Scott
Did you check the access permissions for the underlying node type (the one being referenced) to ensure that Anonymous users have view permissions?
On Thu, May 14, 2009 at 11:34 AM, Scott scott@bscottholmes.com wrote:
I have created a CCK content type that contains a field defined as a node reference. The value in this field is available to logged in users but not to anonymous users. I'm defining a variable thus:
$coupon = $node->field_coupon[0][view];
then later testing for a value, thus:
<?php if ($coupon): ?>
<div id="coupon" class="field field-type-nodereference field-field-coupon"> <?php print "Print ". $node->field_coupon[0][view] . " for " . $node->field_coupon_terms[0][value]; ?></div> <?php endif; ?>
$coupon has a value for logged in users but not for anonymous users. I do have the nid value available ($node->field_coupon[0][nid]) so it is possible to select the referred to node by selecting from the database but I'd rather not if I don't have to.
Thanks, Scott
-- [ Drupal support list | http://lists.drupal.org/ ]
Anonymous users can view the referenced node when called directly, ie /node/20. The problem is that the array element [view] is not populated for anonymous users.
Here is a section of the output from print_r($node) for anonymous user: [field_coupon] => Array ( [0] => Array ( [nid] => 20 [view] => )
)
And for a logged in user: [field_coupon] => Array ( [0] => Array ( [nid] => 20 [view] => Ekizian Coupon )
)
This is true for all the fields defined for this content type, not just the ones used for node reference.
On Thu, 2009-05-14 at 13:02 -0400, William Smith wrote:
Did you check the access permissions for the underlying node type (the one being referenced) to ensure that Anonymous users have view permissions?
On Thu, May 14, 2009 at 11:34 AM, Scott scott@bscottholmes.com wrote:
I have created a CCK content type that contains a field defined as a node reference. The value in this field is available to logged in users but not to anonymous users. I'm defining a variable thus: $coupon = $node->field_coupon[0][view]; then later testing for a value, thus: <?php if ($coupon): ?> <div id="coupon" class="field field-type-nodereference field-field-coupon"> <?php print "Print ". $node->field_coupon[0][view] . " for " . $node->field_coupon_terms[0][value]; ?></div> <?php endif; ?> $coupon has a value for logged in users but not for anonymous users. I do have the nid value available ($node->field_coupon[0][nid]) so it is possible to select the referred to node by selecting from the database but I'd rather not if I don't have to. Thanks, Scott -- [ Drupal support list | http://lists.drupal.org/ ]-- [ Drupal support list | http://lists.drupal.org/ ]
2009/5/15 Scott scott@bscottholmes.com:
Anonymous users can view the referenced node when called directly, ie /node/20. The problem is that the array element [view] is not populated for anonymous users.
Hi Scott, looks like you have enabled field-level access permissions.
Check in admin/build/modules if you have "content permissions" enabled, in the CCK section. If so, you can either disable it (if you don't need to limit access on a per-field level) or enable them individually in admin/user/permissions.
Kind regards, Francesco
That's what it was. Thanks alot.
On Fri, 2009-05-15 at 11:02 +0200, Francesco wrote:
2009/5/15 Scott scott@bscottholmes.com:
Anonymous users can view the referenced node when called directly, ie /node/20. The problem is that the array element [view] is not populated for anonymous users.
Hi Scott, looks like you have enabled field-level access permissions.
Check in admin/build/modules if you have "content permissions" enabled, in the CCK section. If so, you can either disable it (if you don't need to limit access on a per-field level) or enable them individually in admin/user/permissions.
Kind regards, Francesco -- [ Drupal support list | http://lists.drupal.org/ ]