Embedding a View into a Node

By peterm, 9 October, 2009

Tags

For the Title and Pay Plan applicaiton, we are using a technique to display information that embeds a view into a node. You might wonder huh? I know nodes. I know views. Why combine them? Here's a picture of how it is being used.

embedded view

What we've done here is taken a standard node template file, copied it and modified it to suit our purpose. Because I had created a special content type, we're using the template name node-tpp_titles.tpl.php to hold a case statement that embeds a different view depending upon the position type of Title we're looking at (step, open, grade, msp). Below is a snippet of the tpl.php file.

switch ($position_type) { case 'grade_based': print '

'; // set up the view name variable. (grade_child_records is an existing view) $view_grade_child_records = views_get_view('grade_child_records'); // print the view. This will embed the view on the node page print $view_grade_child_records->execute_display('page', $view_args); print '
'; print '

'; break;