mike | Shared With: Everyone - Mar 28 2008 | drupal, views, database
I'm trying to embed a (static) view in a Drupal node (I want to show the employees of a company inside the company node).
This is the first time I've found that there seems to be no Drupal module for doing a common action like this. The two related modules (Insert View and View Field) allow the user to embed a view at edit time of the node. I just want this view statically defined for the node.
It seems pretty insane to have to embed custom PHP for each node that you want to contain a sub-view.
mike | Shared With: Everyone - Jun 27 2008 | dcs08, drupal, module, views, filter
Quoted: The views_filterblock module basically moves the horizontal filter from the views page content area into a (vertical) block. This differs from the views block option which displays the view exposed filters AND a limited number of rows from views content. It themes the block using collapsible fieldsets rather than the table currently used by views, and it uses some logic to decide which fieldsets should be collapsed or not collapsed based on whether the filter form has a value.
ShareViewed: 13 Times
mike | Shared With: Everyone - Jun 05 2008 | drupal, sweet, module, viewsShareViewed: 8 Times
mike | Shared With: Everyone - Mar 29 2008 | tags, drupal, taxonomy, viewsShareViewed: 14 Times
mike | Shared With: Everyone - Mar 27 2008 | views, administration, drupal
Quoted: Views is a powerful query builder for Drupal that allows you to fetch and present lists of content (posts/nodes) to the user in ways that are tailored to your site and your content. Whereas many of the existing tools to do this are more straightforward and easy to use, they also dictate the terms.
ShareViewed: 3 Times

- mike - Mar 30 2008
You must be Mike's friend before you can comment on this Fave.There is a small amount of PHP required to do this. The basic technique is to create a sub-view which you will display when the parent node is displayed. But, in order to get the correct filter, you have to add an "argument" to the sub-view using the CCK reference node field to the parent node. Since this is a numeric arguement, you have to write a small amount of PHP while copies the node id (nid) to the view argument variable (Note: Arguments are really just parameterized Filters who's values can come from the current URL via string matching or from custom PHP as described here).
- Admin/Views:
- Create a Block-type view for your sub-view.
- Add any fields or view type you would normally use.
- Add an Argument of type Node Reference: <Parent Node Type>
- In the Argument Handle Code paste in:
----------------
if ($view->build_type == 'block' && arg(0) == 'node' && is_numeric(arg(1))) {
$args[0] = arg(1);
}
return $args;
----------------
- Save
- Admin/Blocks:
- Configure the block to display only on the parent node path (e.g., "companies/*" - assuming you're using pathauto).
It's not that elegant - but it's a very minimal amount of additional PHP code.
Send Mike a friend request or a personal message instead.