SawRed Development Blog.

Views 3.x Node Argument


Posted on 16th May, by Matt in Drupal. No Comments

In using Views 3 recently, I found, as I’m sure most everyone else has, that it has had some significant changes in the new release. The one that got me recently was triggering the display of a Content field with the argument based on the current node ID.

Before, in Views 2, it required a Node: NID argument, with the default argument being a couple lines of PHP:

if (arg(0) == 'node' && is_numeric(arg(1))) {
    $args[0] = arg(1);
}
return $args;

Now in Views 3, everything is done with “Contextual Filters”. To accomplish the same thing in Views 3 add a Contextual Filter under Advanced. “Provide Default Value” -> Content ID From URL.

Done.


Related content:

  1. Using views_embed_view




Leave a Reply

Connect with Facebook