You are here

function _popup_view in Popup 7

Same name and namespace in other branches
  1. 8 includes/popup.api.inc \_popup_view()
  2. 7.x includes/popup.api.inc \_popup_view()
  3. 6.x includes/popup.api.inc \_popup_view()

File

includes/popup.api.inc, line 409

Code

function _popup_view($attributes, $return = FALSE) {
  $title = FALSE;
  $body = FALSE;
  if (module_exists('views')) {
    $view = views_get_view($attributes['view']);
    $display = $attributes['display'] ? $attributes['display'] : 'default';
    $args = isset($attributes['args']) ? explode(',', $attributes['args']) : array();
    if ($view) {
      $view
        ->set_arguments($args);
      $view
        ->set_display($display);
      $body = $view
        ->preview();
      $computed_title = $view
        ->get_title();
      $title = $attributes['title'] ? $attributes['title'] : ($computed_title ? $computed_title : @$view->display[$display]->display_options['title']);
    }
  }
  else {
    $body = false;
  }
  $title = $title ? $title : 'View';
  if ($return == 'title') {
    return $title;
  }
  if ($return == 'body') {
    return $body;
  }
  return popup_element($title, $body, $attributes);
}