By sid16 on
Need some help with passing Node ID to a view that's attached to a node teaser. The view needs to be filtered by the Node ID of the node that's in the teaser. I can't seem to do this with the Node ID from URL argument. Is there custom PHP code I can enter in the arguments settings for this ?
Comments
How are you attaching the
How are you attaching the view to the node teaser?
I'm using Display Suite to
I'm using Display Suite to place the views block in my node teasers. I can still pass arguments to the view this way, it works on full nodes. I need to do the same thing for teasers.
In Display Suite under "Node
In Display Suite under "Node Displays", under "Fields", add a new "Add new code field".
For the code try something like
Then add this field to the teaser display for the content type.
Ok, I tried that, but it
Ok, I tried that, but it still doesn't work. The view is displaying all the values. Is there any other way to pass the node ID to the view ?
Does the view expect a node
Does the view expect a node id (nid) as an argument?
can you explain that please?
can you explain that please? only the node id argument would ensure the values in the view match that of the node in the teaser, right?
To explain what I want to do, here's an example. Let's say I have two nodes, called 'Fruit' and 'Vegetable.' When viewed as teasers (like on a taxonomy page or search results), the teaser for 'Fruit' has a block view that displays apples, strawberries, etc. The teaser for 'Vegetable' shows carrots, onions, etc.
It sounds like you want a
It sounds like you want a view to list all the content of a certain type. If that is the case you could
a) Make a view that takes Node: Type as a view.
b) Make two views (or one view with two blocks) that has a Node: Type filter.
The later may prove easier for what you want.
An alternate approach is to
An alternate approach is to use the View Field module.
Thanks, nevets! Viewsfield
Thanks, nevets! Viewsfield did the trick.