mediatribe.net -- Drupal and Web Development

Notice: this post was last updated 6 years 27 weeks ago so it might be outdated. Please be cautious before implementing any of suggestions herein.

Displaying a block with a field from the current node using Views 2 and Drupal 6

I have a CCK field with an image on my page nodes. I want to display a block with the CCK field value on its related node, but nothing on non-pages.

This often works in the views preview, but not on the actual page. This was driving me nuts and I spent a few hours finding this solution:

Create view with

  • Filter: node nid > 0
  • Argument: node nid, Action to take if argument is not present: Provide default argument: node nid from URL; validator: basic. Action to take if does not validate: Hide view
  • Create a new block display and you're done!

Wow

Big thanks for this. Exactly what I was looking for :)

This is EXACTLY what I was

This is EXACTLY what I was looking for. Thanks so much for posting this. I took me a while to find this post, but I knew the answer had to be somewhat simple.

I'm new to coding...anyone

I'm new to coding...anyone have an example of the code for the argument??

Thanks!

If you're using Views 3 (and

If you're using Views 3 (and perhaps even using Views 2), neither the validator nor the filter are needed. Use only a Contextual Filter (Argument) for Content: Nid with a Default Value of Content ID from URL.

No code necessary for the argument in either case.

-- Don

Thanks--this is exactly what

Thanks--this is exactly what I needed to create my custom node view.

Works with Drupal 7 Panels

Works with Drupal 7 Panels and views. thanks!