Same name in other branches
- 8.x-1.x src/Plugin/QuickRender/QuickQuicktabs.php \Drupal\quicktabs\Plugin\QuickRender\QuickQuicktabs::render()
Overrides QuickRenderer::render
Fichier
-
plugins/
QuickQuicktabs.inc, line 9
Classe
- QuickQuicktabs
- Renders the content using the original Quicktabs mechanism of previous versions. Includes support for ajax rendered content.
Code
public function render() {
$quickset = $this->quickset;
$render_array = array();
$active_tab = $quickset->getActiveTab();
if ($tabs = $this->build_tablinks($active_tab)) {
$render_array['#attached'] = $this->add_attached();
$qt_name = $quickset->getName();
$settings = $quickset->getSettings();
$contents = $quickset->getContents();
$render_array['content'] = array(
'#theme' => 'qt_quicktabs',
'#options' => array(
'attributes' => array(
'id' => 'quicktabs-' . $qt_name,
'class' => 'quicktabs-wrapper quicktabs-style-' . drupal_html_class($settings['style']),
),
),
'tabs' => array(
'#theme' => 'qt_quicktabs_tabset',
'#options' => array(
'active' => $active_tab,
'style' => drupal_html_class($settings['style']),
),
'tablinks' => $tabs,
),
// The main content area, each quicktab container needs a unique id.
'container' => array(
'#prefix' => '<div id="quicktabs-container-' . $qt_name . '" class="quicktabs_main quicktabs-style-' . drupal_html_class($settings['style']) . '">',
'#suffix' => '</div>',
'divs' => array(),
),
);
// If in ajax mode, we'll only be rendering one tab, otherwise all of them.
if ($settings['ajax']) {
// check in case of $active_tab=QUICKTABS_DELTA_NONE
$tabs_to_render = isset($contents[$active_tab]) ? array(
$active_tab => $contents[$active_tab],
) : array();
}
else {
$tabs_to_render = $contents;
}
foreach ($tabs_to_render as $key => $tab) {
if (!empty($tab)) {
$attribs = array(
'id' => 'quicktabs-tabpage-' . $qt_name . '-' . $key,
'class' => array(
'quicktabs-tabpage',
$active_tab == $key ? '' : 'quicktabs-hide',
),
);
$render_array['content']['container']['divs'][] = array(
'#prefix' => '<div ' . drupal_attributes($attribs) . '>',
'#suffix' => '</div>',
'content' => $tab->render(),
);
}
}
}
return $render_array;
}