-- Drupal and Web Development

Notice: this post was last updated 6 years 24 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!


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??


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!

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.