class UiTabs in Quick Tabs 8.3
Provides a 'ui tabs' tab renderer.
Plugin annotation
@TabRenderer(
id = "ui_tabs",
name = @Translation("jquery ui"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\quicktabs\TabRendererBase implements TabRendererInterface
- class \Drupal\quicktabs_jqueryui\Plugin\TabRenderer\UiTabs
- class \Drupal\quicktabs\TabRendererBase implements TabRendererInterface
Expanded class hierarchy of UiTabs
File
- quicktabs_jqueryui/
src/ Plugin/ TabRenderer/ UiTabs.php, line 18
Namespace
Drupal\quicktabs_jqueryui\Plugin\TabRendererView source
class UiTabs extends TabRendererBase {
/**
* {@inheritdoc}
*/
public function render(QuickTabsInstance $instance) {
$qt_id = $instance
->id();
$type = \Drupal::service('plugin.manager.tab_type');
// The render array used to build the block.
$build = [];
$build['pages'] = [];
// Pages of content that will be shown or hidden.
$tab_pages = [];
// Tabs used to show/hide content.
$titles = [];
foreach ($instance
->getConfigurationData() as $index => $tab) {
$object = $type
->createInstance($tab['type']);
$render = $object
->render($tab);
// If user wants to hide empty tabs and there is no content
// then skip to next tab.
if ($instance
->getHideEmptyTabs() && empty($render)) {
continue;
}
$tab_num = $index + 1;
$attributes = new Attribute([
'id' => 'qt-' . $qt_id . '-ui-tabs' . $tab_num,
]);
if (!empty($tab['content'][$tab['type']]['options']['display_title']) && !empty($tab['content'][$tab['type']]['options']['block_title'])) {
$build['pages'][$index]['#title'] = $tab['content'][$tab['type']]['options']['block_title'];
}
$build['pages'][$index]['#block'] = $render;
$build['pages'][$index]['#prefix'] = '<div ' . $attributes . '>';
$build['pages'][$index]['#suffix'] = '</div>';
$build['pages'][$index]['#theme'] = 'quicktabs_block_content';
$href = '#qt-' . $qt_id . '-ui-tabs' . $tab_num;
$titles[] = [
'#markup' => '<a href="' . $href . '">' . new TranslatableMarkup($tab['title']) . '</a>',
];
$tab_pages[] = $tab;
}
// Add a wrapper.
$build['#theme_wrappers'] = [
'container' => [
'#attributes' => [
'class' => [
'quicktabs-ui-wrapper',
],
'id' => 'quicktabs-' . $qt_id,
],
],
];
$tabs = [
'#theme' => 'item_list',
'#items' => $titles,
];
// Add tabs to the build.
array_unshift($build, $tabs);
// Attach js.
$default_tab = $instance
->getDefaultTab();
$build['#attached'] = [
'library' => [
'quicktabs_jqueryui/quicktabs.ui',
],
'drupalSettings' => [
'quicktabs' => [
'qt_' . $qt_id => [
'tabs' => $tab_pages,
'default_tab' => $default_tab,
],
],
],
];
return $build;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
TabRendererBase:: |
public | function | Gets the name of the plugin. | |
TabRendererBase:: |
public | function |
Return form elements used on the edit/add from. Overrides TabRendererInterface:: |
2 |
UiTabs:: |
public | function |
Return a render array for the whole Quick Tabs instance. Overrides TabRendererBase:: |