Can somebody tell me how I can list views in a specific content type?

Thanks
Jakob

Comments

luyendao’s picture

$view = views_get_view('view_name');
print views_build_view('embed', $view);

Just a stick it into the template for the content type you want to apply it to.

Lu

205 CTT’s picture

Thanks alot !!
Dos it mean that I find the template for the specific content type and place the code above into it? (I am quit new to this)

*****
Another question:
I want to have a panel on each site of a specific content type. On top the actual text/node and in the bottom two collumns with a view in each collumn. Is it possible to have a panel not just on one page, but on every page within a content type?

Thanks
Jakob

luyendao’s picture

Here's another drupal post related to embedding views:
http://drupal.org/node/47417
You can also pass in arguments, and set the # of returned items from the embed code...there's quite a number of things you can do.

For your 1st question, yes you have to find the template associated with the node type, and place the embed code above it. So if you're changing stories, edit node-story.tpl.php

For your 2nd question, are you referring to the panels module when you say panel? If i understand what you're saying, on a certain node type, let's say all 'article' templates, you want two listings in two columns, one for 'cookie recipes' and the other for 'bread recipes' as an example.

In that case, just embed two views - let the views do the filtering by content type, and *only* add these views to node type specific templates, and don't add it to other ones. That's the easiest way to do it. Remember when embed views you have to use the system name of the view (the first field in a view), not the view url.