'admin/settings/views-tabs', 'title' => t('Views Tabs'), 'description' => t('Set display options.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('views_tabs_admin_settings'), 'access' => user_access('administer site configuration'), ); } return $items; } /** * Administration settings form. */ function views_tabs_admin_settings() { $form = array(); $options = array('0' => t('none')) + drupal_map_assoc(array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200)); $form['views_tabs_truncate_length'] = array( '#type' => 'select', '#title' => t('Maximum length of tab titles'), '#default_value' => variable_get('views_tabs_truncate_length', 0), '#options' => $options, '#description' => t('Views presented on tabs use content titles for the tab titles. You can limit the length of these tab titles by selecting a maximum length here. Titles will be cut (truncated) to the nearest word. Choose "none" to display full titles.'), ); return system_settings_form($form); } /** * Implementation of hook_views_style_plugins() */ function views_tabs_views_style_plugins() { $plugins = array(); $plugins['tabs_fields'] = array( 'name' => t('Tabs - Fields'), 'theme' => 'views_tabs_display', // Reuse the validation for lists as this covers // the needed functionality. 'validate' => 'views_ui_plugin_validate_list', 'needs_fields' => TRUE, 'needs_table_header' => FALSE, ); $plugins['tabs_teaser'] = array( 'name' => t('Tabs - Teaser List'), 'theme' => 'views_tabs_display', ); $plugins['tabs_node'] = array( 'name' => t('Tabs - Full Nodes'), 'theme' => 'views_tabs_display', ); return $plugins; } /** * Display the nodes of a view on tabs. */ function theme_views_tabs_display($view, $nodes, $type, $teasers = FALSE, $links = TRUE) { $fields = _views_get_fields(); $tabset = array( '#type' => 'tabset', ); foreach ($nodes as $node) { switch ($view->type) { case 'tabs_fields': $item = ''; foreach ($view->field as $field) { if ($fields[$field['id']]['visible'] !== FALSE) { if ($field['label']) { $item .= "
" . $field['label'] . "
"; } $item .= "
" . views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view) . "
"; } } $title = check_plain($node->node_title); $content = "
name) ."'>$item
\n"; break; case 'tabs_teaser': case 'tabs_node': $node = node_load($node->nid); $content = node_view($node, $teasers, FALSE, $links); $title = check_plain($node->title); break; } if ($length = variable_get('views_tabs_truncate_length', 0)) { $title = truncate_utf8($title, $length, TRUE, TRUE); } $tabset[$title] = array( '#type' => 'tabpage', '#content' => $content, '#title' => $title, ); } if (element_children($tabset)) { return tabs_render($tabset); } }