function template_preprocess_blocktabs in Block Tabs 8
Prepares variables for blocktabs templates.
File
- ./
blocktabs.module, line 60 - Provides block tabs.
Code
function template_preprocess_blocktabs(&$variables) {
$blocktabs = $variables['elements']['#blocktabs'];
$tabs_id = 'blocktabs-' . $blocktabs
->id();
$variables['tabs_id'] = $tabs_id;
$classes_array = [];
$classes_array[] = 'blocktabs';
$event = $blocktabs
->getEvent();
if (!empty($event)) {
$classes_array[] = $event;
}
$style = $blocktabs
->getStyle();
if (!empty($style)) {
$classes_array[] = $style;
}
$variables['attributes']['class'] = $classes_array;
$variables['tabs'] = [];
$tabs = $blocktabs
->getTabs();
foreach ($tabs as $tab) {
$tab_id = $tabs_id . '-' . $tab
->getWeight();
$tab_obj = new stdClass();
$tab_obj->title = $tab
->getTitle();
$tab_obj->id = $tab_id;
$tab_obj->content = $tab
->getContent();
if (!empty($tab_obj->content)) {
$variables['tabs'][$tab_id] = $tab_obj;
}
}
}