Help filtering a view by node ID

Jboo - March 27, 2008 - 15:00

Hi,

I have cck fields that are used when creating a node which I have now added to a view. After adding the view to a page it displays all of the cck field results on the same page rather than the field results that are related specifically to the node. For example if I have three nodes, each of them will display the cck field results from ALL nodes rather than for their own node ID only.

Can anyone explain how I can filter the view to only show results from the specific node ID?

Thanks for any help.

Why use a view, you can view

nevets - March 27, 2008 - 15:08

Why use a view, you can view a single node as node/{nid} where {nid} is a node id (a number).

I think you might be getting

nicholasbarcomb - March 27, 2008 - 17:09

I think you might be getting node id confused with node type. The nid is the specific # of the node like how in the URL it'll say site/node/62, the 62 is the node id. The node type is what content type it is, like blog, story, page, etc. Ti filter by nid is to show one that node or everything but that node (the "is one of","is none of" options).

Now this bit about the fields is a bit confusing to me. If you want to show only some field made by cck there are 2 ways to do it. In the Create Content section, when you go in to edit the content type there should be a tab at the top that says Display, this is where you can hide things from the teaser and full node views. The other way is to go into Views and choose "List" or "Table" as your ViewType in the page and/or block sections. With one of these selected you are free to use the Fields section of Views. Here is where you declare what gets shown from each node in the View.

Hope this was helpful
-Nick

Thanks for the

Jboo - March 27, 2008 - 19:23

Thanks for the replies.

nevets - i'm using panels so that I can easily change the layout and also add any other views and blocks that I might need rather than using regular nodes. So i've basically opened up the cck fields to panels and adding any fields I need to panel pages.

Nick - thanks for the explanation. However, I can't work out how to filter so that the correct fields are only displayed on the node ID it's meant to. I'll try and explain a bit better! I create 2 nodes and fill in any fields I have on the node creation form. When viewing the 2 nodes I have just created, all of the fields are displayed on both nodes rather than just the fields that match the node ID.
Example...

Node Title 1 (node/1)
January (CCK field result)

Node Title 2 (node/2)
February (CCK field result)

When viewing node/1 and node/2 all of the CCK fields are displayed (January, February) on both pages rather than January for node/1 only and February for node/2 only.

I thought it would be as easy as adding a filter for the view for node ID but I can't seem to find anything in the filters tab on the views settings. I know I can filter by node:type with the "is one of" and "is none of" options, but it seems as though I need to filter by node ID to get the fields to match up to the correct node. In the arguments section of the views settings there is an option called Node:ID. Do I need to set this option or is there something I'm missing?

Thanks again for your help, it's much appreciated.

You want to use arguments

nevets - March 27, 2008 - 19:43

You want to use arguments (and not filters) to limit the results to a single node. Under "Arguments" select "Node: ID" as the argument.

I'm a bit confused as to

mr_dimsum - March 27, 2008 - 19:55

I'm a bit confused as to what you want to do? Do you want to filter to just one node "type" or something otherwise? If so, I believe just adding a filter and selecting the Node Type does the trick. I'm not too sure why you would only want to filter by Node ID.. Wouldn't this just result in 1 x node being displayed?

this might give another example (unresolved)...

avolve - April 25, 2008 - 08:31

I can provide an example of something i have tried to do, though couldn't seem to resolve, which might provide a reason for trying this.

I wanted to have a panel with 3 tabs, each one being a single node (either teaser with link to full node, or ful node). The only way i could achieve this was to add 'custom content' panes. There seemed to be no way to reference a node directly.

I tried to make views that would pull out the single nodes as a workaround, though (perhaps resulting from my limited experience with views arguments), i could not achieve this. If i used NodeID i always ended up with all nodes from the specific content type...

I am looking at other ways given the URL that panel tabs generates, more-so iven i have not resolved how to pull in a single node. As for what this other was is, i am not sure.

To resolve my problem i

Jboo - April 25, 2008 - 10:32

To resolve my problem i created a panel view out of the view i'd created. In the panel view I could then have the "argument source" from context and "required context" as node. This gives me single node fields.

Thanks nevets, that's what I

Jboo - March 27, 2008 - 22:42

Thanks nevets, that's what I thought it might be. Upon selecting Node:ID under arguments, without changing any other settings, the view disappears from the node. Should I enter anything under the "Default", "Title", "Option", "Wildcard", or "Wildcard sub" settings?

mr_dimsum - the view is being added to an overidden content type so I need the fields to match up to the correct node ID.

Thanks for your help.

How are you setting up your

nevets - March 28, 2008 - 02:51

How are you setting up your panel page? Does it use a node context? And how are you setting the options for the view when you add it to the panel?

The panel page settings

Jboo - March 28, 2008 - 11:08

The panel page settings (under the context tab) just has Node ID as an argument. As for the view itself when adding to the panel I haven't changed any options as I don't see any that seem relevant (just title, css class, etc when configuring the pane). You can tell I'm a noob!

 
 

Drupal is a registered trademark of Dries Buytaert.