function views_embed_view

cis7 views.module views_embed_view($name, $display_id = 'default')
cle7 views.module views_embed_view($name, $display_id = 'default')
elmsmedia7 views.module views_embed_view($name, $display_id = 'default')
icor7 views.module views_embed_view($name, $display_id = 'default')
meedjum_blog7 views.module views_embed_view($name, $display_id = 'default')
mooc7 views.module views_embed_view($name, $display_id = 'default')

Embed a view using a PHP snippet.

This function is meant to be called from PHP snippets, should one wish to embed a view in a node or something. It's meant to provide the simplest solution and doesn't really offer a lot of options, but breaking the function apart is pretty easy, and this provides a worthwhile guide to doing so.

Note that this function does NOT display the title of the view. If you want to do that, you will need to do what this function does manually, by loading the view, getting the preview and then getting $view->get_title().


$name: The name of the view to embed.

$display_id: The display id to embed. If unsure, use 'default', as it will always be valid. But things like 'page' or 'block' should work here.

...: Any additional parameters will be passed as arguments.


sites/all/modules/ulmus/views/views.module, line 2191
Primarily Drupal hooks and global API functions to manipulate views.


function views_embed_view($name, $display_id = 'default') {
  $args = func_get_args();
  array_shift($args); // remove $name
  if (count($args)) {
    array_shift($args); // remove $display_id

  $view = views_get_view($name);
  if (!$view || !$view->access($display_id)) {

  return $view->preview($display_id, $args);



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.