public function ViewsTab::getContent in Block Tabs 8
Returns the content of the tab.
Return value
string The content of the tab.
Overrides TabBase::getContent
File
- src/
Plugin/ Tab/ ViewsTab.php, line 138
Class
- ViewsTab
- Views tab.
Namespace
Drupal\blocktabs\Plugin\TabCode
public function getContent() {
$tab_content = '';
$view_name = $this->configuration['view_name'];
$view_display = $this->configuration['view_display'];
$view_arg = !empty($this->configuration['view_arg']) ? $this->configuration['view_arg'] : NULL;
$view = Views::getView($view_name);
$view
->setDisplay($view_display);
$view
->setArguments($view_arg);
$view
->execute();
$count = count($view->result);
//$tab_view = $view->render();
if (!empty($this->configuration['display_tab']) || $count > 0) {
//$view_arg = !empty($this->configuration['view_arg']) ? $this->configuration['view_arg'] : NULL;
$tab_content = views_embed_view($view_name, $view_display, $view_arg);
}
else {
$tab_content = NULL;
}
return $tab_content;
}