0

I'm using Drupal 7, with the Views module version 3, and the Context module (no block).

I have a draggable view I want to show on a gallery node. The draggable view shows the image nodes belonging to this gallery node for sorting.

Now I want to limmit the display of this view to the author of the gallery node. (Only the author of the gallery node should organize the image nodes.) I think this could be done with context or relationship (and some coding) inside views, but I don't know how.

I know how I can display the view only on the gallery-node (via Context module). So I only need a way to limit the display of the view to the author of the gallery.

Maybe someone has a solution.

1

You just need to add an argument to this, passing the logged in user's uid. In Drupal 6, views 2 you used to have to reverse engineer this and add custom php into the argument handling code but this is built into Views 3. In your view:

  • Add Contextual filter, 'Content: author uid'
  • Select 'provide default value', type 'user id from logged in user'

This will find the uid of the logged in author and pass that as an argument to your view, restricting the view results to only items that were authored by the owner of that node.

  • Thank you for your reply, I have done this by adding a contextual filter in my view, setting the default value "user ID from url" and adding a php-validator with the following code: global $user; return $argument[0] == $user->uid; – kay Feb 6 '12 at 21:11
  • Thank you for your reply, I have done this by adding a contextual filter in my view, setting the default value "user ID from url" and adding a php-validator with the following code: global $user; return $argument[0] == $user->uid; Now all displayed image nodes are owned by the logged in user. But I need a view with all image-nodes (also of other users) but the view should only be displayed if the logged in user is owner of the gallery-node (where the views-block is displayed). I'm sorry for the weird description. Is this possible? – kay Feb 6 '12 at 21:18
  • Thank you for your help, after some trying I changed my concept. The view shows all image-nodes (without filtering of the owner) belonging to the gallery. I took the views template and check there if the logged in user is the owner of the gallery-node. Maybe there is a better way but for for now it is ok for me. – kay Feb 8 '12 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.