In my use case I would like to be able to display a node reference (just the teaser) even if the user doesn't have permission to view the full node. Of course if I could display the whole node then I can use the cck display format to only display the teaser. I am looking through the code to see how this might be possible.

Any ideas?

Comments

webservant316’s picture

my problem solved with this one line hack/addition. added this line to 349 of nodereference.module

function theme_nodereference_formatter_full_teaser($element) {
  static $recursion_queue = array();
  $output = '';
+  if ( stripos($element['#field_name'],"grant") != FALSE ) { $element['#item']['safe']['nid'] = $element['#item']['nid']; } // allow view of node reference without perms if 'grant' in cck field name
  if (!empty($element['#item']['safe']['nid'])) {
    $nid = $element['#item']['safe']['nid'];

Perhaps this feature could be added in a better way.

KarenS’s picture

Status: Active » Closed (won't fix)

We're not going to add a feature that bypasses Drupal's permissions. If someone is not supposed to view the node they should not see the teaser. If you have some special use case where you want to do that it is something you will have to do yourself.

webservant316’s picture

Fair enough, but one last thought.

You could add a Drupal perm that stands along side the node reference module that grants permission to see the contents of a referenced node even if you do not have perm to access the node directly. It could be part of the 'CCK Content Permissions' and the perm could be called 'view node reference override'. It could default to off and even when it is on admins could further control access to the content using the CCK field display options.

Solving the problem this way would not bypass the Drupal perms, but expand their capability and flexibility.

Further it is not true in all use cases that someone who cannot see the whole node should not see the teaser. In my use case I do need to ability for users to view part of the node but not the full node until access is purchased via Ubercart node access. I had two choices. 1) restrict the whole node but grant access to the teaser as I have done OR 2) grant the whole node, but restrict a particular set of fields with CCK field perms. I went with the first option because the Ubercart module to sell node access is better than the Ubercart module to sell field access.

Reconsider?