vc_embed_view()

Public

When use views_embed_view(), the forms rendered inside the view does not work. This function can help.

</> CopyGet raw version
php
  1. /**
  2.  * An other function to embed a view, support sending context path.
  3.  */
  4. function vc_embed_view($options) {
  5. $name = $options['name'];
  6. $display_id = !empty($options['display_id']) ? $options['display_id'] : 'default';
  7. $path = !empty($options['path']) ? $options['path'] : NULL;
  8.  
  9. $args = func_get_args();
  10. array_shift($args); // remove $options
  11.  
  12. $view = views_get_view($name);
  13. if (!$view || !$view->access($display_id)) {
  14. return;
  15. }
  16.  
  17. if (!empty($path)) {
  18. $view->override_path = $path;
  19. }
  20.  
  21. return $view->preview($display_id, $args);
  22. }