To insert views into node content, we use "views_embed_view" function. This is a simplest solution to inset views into node content. This function does not display the title of the view.
views_embed_view($name, $display_id = 'default', $arg)
$name : name is the machine name of the view to embed.
$display_id : The display id of the view to embed. A view can have multiple display, so you need to assign correct dispaly id of the view which you want to embed. If you are not sure about the display id of view, then defined "default" as display id. You can also defined "block" or "page" as display id, if there is block or page display exist in your view.
$arg : This is the arguments passed to view. If your view contains the arguments, you can defined the value for this otherwise you can skip this parameters.
Finding the correct Parameters:
- Go to administration -> structure -> view
- Edit any view which you want to embed. The url of the view will be as "admin/structure/views/view/machine_name_of_view/edit".
- Hover on block or page display of view which you want to embed. The url of display defined as "admin/structure/views/view/machine_name_of_view/edit/dislay_id".
Now, you can get the correct parameters of the view for the above function.
Example: embedding "recent comments" block in node content.
- Go to administration -> structure -> view.
- By default, "recent comments" view are disabled. Enabled the view by clicking on "enable" link in operations of the view.
- Edit the "recent comments" view and hover the block display and it will display the "machine_name" and "dispaly_id" of the view.
Now, in the node.tpl, write the below code to embed recend comments in the node content. As there is no arguments in the view, so you can skip the arguments parameter.