On Monday 19 January 2009 9:17:07 pm Michael Prasuhn wrote:
On Jan 19, 2009, at 6:21 PM, Larry Garfield wrote:
Yes you can. Views_attach creates a new display type for Views (along with Block, Page, etc.) that attaches itself to nodes of a given type that you specify. You can also use an argument that takes a nid from the URL (either nid or a nodereference) to make the view contextual to the node it's on, which is where the fun stuff happens. You can then order where that view will appear using the CCK Manage fields page. It works for users, too.
Okay, I thought I had this figured out, but upon further testing, I don't see how to specify the argument. I have defaults and a 'Node Content' display on my view, so I have no path to put %1 into, to tell it where to pull the argument from. I thought maybe there would be an option under the Display settings, to use the node ID as an argument, (similar to panels integration where you can choose the source of arguments) but I don't see anything like that.
So I can't figure out how to pass the node ID to view without it being a page with an argument in the path for the page display.
-Mike
Arguments work on any display, not just pages. There's just no obvious way to get content to the argument without using the path. However, arguments can also have default values.
So setup a node content display, add an argument of "node id", and give it a default value of "get nid from URL" (or whatever it's called). Now the view will always get an argument of the node id of the node it's attached to. Poof. :-)