Same name in other branches
- 8.x-1.x src/Plugin/QuickContent/QuickViewContent.php \Drupal\quicktabs\Plugin\QuickContent\QuickViewContent::render()
Overrides QuickContentRenderable::render
File
-
plugins/
QuickViewContent.inc, line 84
Class
- QuickViewContent
- Class for tab content of type "view" - this is for rendering a view as tab content.
Code
public function render($hide_empty = FALSE, $args = array()) {
if (!empty($args)) {
// The args have been passed in from an ajax request. We use Views' own
// ajax functionality to get the view.
// The first element of the args array is the qt_name, which we don't need
// for this content type.
array_shift($args);
// The order of these arguments corresponds to the array returned in
// $this->getAjaxKeys().
$_REQUEST['view_name'] = array_shift($args);
$_REQUEST['view_display_id'] = array_shift($args);
$_REQUEST['view_dom_id'] = array_shift($args);
$view_path = array_shift($args);
$_REQUEST['view_path'] = rawurldecode($view_path);
if (!empty($args)) {
$view_args = array_shift($args);
$_REQUEST['view_args'] = rawurldecode($view_args);
}
module_load_include('inc', 'views', 'includes/ajax');
$view = views_ajax();
foreach ($view['#commands'] as $command) {
if ($command['command'] == 'insert') {
return array(
'#markup' => trim($command['data']),
);
}
}
return array();
}
// Non-ajax rendering of a view.
if ($this->rendered_content) {
return $this->rendered_content;
}
$item = $this->settings;
$output = array();
if (isset($item['vid'])) {
if (module_exists('views')) {
if ($view = views_get_view($item['vid'])) {
if ($view->access($item['display'])) {
$view->set_display($item['display']);
$view->set_arguments($item['actual_args']);
$view_output = $view->preview();
if (!empty($view->result) || $view->display_handler
->get_option('empty') || !empty($view->style_plugin->definition['even empty'])) {
$output['#markup'] = $view_output;
}
}
elseif (!$hide_empty) {
$output['#markup'] = theme('quicktabs_tab_access_denied', array(
'tab' => $item,
));
}
if (isset($this->settings['use_title']) && $this->settings['use_title'] > 0) {
$this->title = $view->get_title();
}
$view->destroy();
}
}
elseif (!$hide_empty) {
$output['#markup'] = t('Views module is not enabled, cannot display content.');
}
}
$this->rendered_content = $output;
return $output;
}