function commons_bw_generate_group_widget in Drupal Commons 7.3
Generate a renderable group widget.
Parameters
$group: An optional group node to be used as a tab and views argument.
Return value
array An array in the format expected by drupal_render().
1 call to commons_bw_generate_group_widget()
- commons_bw_commons_bw_group_content_type_render in modules/
commons/ commons_bw/ plugins/ content_types/ commons_bw_group.inc - Output function for the '[content_type]' content type.
File
- modules/
commons/ commons_bw/ commons_bw.module, line 430
Code
function commons_bw_generate_group_widget($group = NULL) {
// Prepare an array of default quicktabs settings.
$settings = array(
'style' => 'Commons Pills',
'ajax' => FALSE,
'html' => TRUE,
);
// Load the browsing widget tab definitions.
$tabs = commons_bw_get_tab_definitions('group');
foreach ($tabs as $machine_name => $tab_settings) {
// Populate the group argument.
$tabs[$machine_name]['args'] = $group ? $group->nid : 0;
// Add the result count to the title for 'view' tabs.
if ($tab_settings['type'] == 'view') {
// Get the view specified by the tab settings.
$view = views_get_view($tab_settings['vid']);
// If the tab specified a view display use it, otherwise the view will be
// rendered using the default display.
if (isset($tab_settings['display'])) {
$view
->set_display($tab_settings['display']);
}
// If the tab references a group, set it as a tab argument.
if ($group) {
$view
->set_arguments(array(
$group->nid,
));
}
$view->display_handler->options['filters']['flagged']['value'] = 'All';
$view->get_total_rows = TRUE;
$view
->execute();
// Append the result count to the tab title.
$tabs[$machine_name]['title'] = $tabs[$machine_name]['title'] . ' <span class="commons-bw-result-count">' . $view->total_rows . '</span>';
}
// Use the current tab as the quicktabs default if the tab settings specify.
if (!empty($tabs[$machine_name]['default'])) {
$settings['default_tab'] = $machine_name;
}
}
return quicktabs_build_quicktabs('commons_bw', $settings, $tabs);
}