Hi, I'm wondering if there is a way to apply output of a View ONLY to a specific node type?
More specifically, I have created a view with a page display that I would like to apply only to nodes of content type Product.
At first I thought it would be a good idea to use Node ID as an argument and apply it to a path of "node/%" but then I realized that it would affect all content types b/c it uses "node" in the path.
Someone may suggest using Ubercart if I am doing anything with Products, but I avoided using Ubercart b/c it has too many functions that I don't need.
Any help would be much appreciated.
Comments
Comment #1
merlinofchaos commentedViews can't do this without some help, since you need something that will do routing. Page Manager + Panels can do routing on the node and allow displaying different content by node type.
Comment #2
Anonymous (not verified) commentedthanks for the tip! i will look in to it!
Comment #3
Anonymous (not verified) commentedit works! thank you so much!
Comment #4
Anonymous (not verified) commentedComment #5
rondog489 commentedHi I am trying to achieve this same thing. I cant seem to find a module called 'Page Manager'. I found panels but thats it. Am I missing something?
Comment #6
merlinofchaos commentedPage Manager is part of CTools: http://drupal.org/project/ctools
Comment #7
lsdoc77 commentedYou can do it only with views..there is a workaround for this..
1.First you create a view with a page display and set the path to /node/% so that this view is shown on every node page..
2.You create two arguments :
a. The first is the nid with basic validation so that it displays only the current node...
b. Another argument with node->type validator:node and you chose the type of content that you want to override..(the argument type is left to Node Id).
So until now if you check you will see that you have the view printed for the content type that you selected in step 2b and nothing shown on the pages of the other content types. That's why you have to :
3. edit the 'empty text' of the view ( on the left column) and with the php input filter enabled paste the following code :
So if the content type of the current node is not the desired instead of printing nothing it manuallly prints the node..
I know it's a little bit messy to do all this circle instead of using panels , but I believe that with views you can do almost anything.. ;-)
Comment #8
haysuess commentedI tried the instructions in #7 and it is not working. It makes complete sense and I am sure I followed your directions correctly. Is there something else?
Comment #9
haysuess commentedLooks like you said it backwards...
The Node:nid argument validator should be node->type with the type you want to override checked and set to display empty text
The Node: type argument validator should be basic
That works for me!
Comment #10
datarazor commentedThere are actually a zillion ways to do this (as is typical with Drupal).
For example: You can use Context to enable a Views block that grabs the argument and turns off the content region when satisfied. (or use the view as a "block-like" attachment.
Or you can use the module EVA and associate it to the particular node.
https://drupal.org/project/Eva
Or you can edit the node.tpl.php to load a view and pass it your NID value.
Or you can use a custom path for the view, and the argument for the node can be in the URL
Hope this helps someone to see the other ways of the Drupal-force.