2

Case is that im using views for displaying each of content-types.

eg. q=?news/12 for news by nid q=?product/13 for products by nid

Problem is when im creating (or editing) new content, it automatically displays (or refer) ?node/14 instead of ?product/14. Also menu link is created under node/14 link.

How could i set each view to referring content type?

Thanks in advance.

Gregor
  • 385
  • 3
  • 15

1 Answers1

6

You can create a view (display mode : page) for each content type, which displays datas from your node (fields or whatever you need). To do so, add a contextual filter in your view, on content nid, give default value : content nid from URL. Then give to this view a URL like /news/%. So /news/12 hits this view and grabs data from news content type with id 12. Then you can manually modify menu link, or use Pathauto to specify /news/[node:nid] as a pattern for all your news nodes (I never tried all this stuff together but it should work).

Other solution

https://www.drupal.org/project/contemplate (seems deprecated...)

Other solution

Create a dedicated template file for your content type nodes : node--news.tpl.php, but no more views...

Other solution

Create a view displaying one particular node data (like I explained first, with a contextual filter), this view creates a block (display mode : block), you assign this block to a region (with block interface), and set this block to be displayed only for the news content type (last menu on the left on the block configuration page). Then with Display Suite you hide everything for this content type on the Full content display. So on each node page which refers to a news node, you have nothing in your page but your block (and the node title, which you can remove with Display Suite Extras I guess).

Good luck with it

Florian Motteau
  • 3,467
  • 1
  • 22
  • 42
  • Tried last solution. Works like a charm! Thank you! – Gregor Dec 07 '14 at 21:15
  • Huh, i tried with one contentType where url was /node/%. But its not working with multiple types. So i set the path of views to /node/%/products or views. I tried last solution but it didnt worked. I set the Exposed form to block to yes, and assigned that block to a region in block interface. But is seems like its not displaying any of assigned blocks. – Gregor Dec 08 '14 at 17:45
  • You can also try the "block region" option in Display Suite extras, it allows you to define a field wrapper in display suite, which will be rendered as a block, available in the block interface : https://www.drupal.org/node/1795354. I worked with it recently, it can be very usefull (and simple) – Florian Motteau Dec 09 '14 at 18:55