The Quick Tabs module allows you to create blocks of tabbed content. You can create a block on your site containing up to six tabs with corresponding content. Clicking on the tabs makes the corresponding content display instantly (it uses jQuery). The content for each tabbed section can be either a view or an existing block. It is an ideal way to do something like the Most Popular / Most Emailed stories tabs you see on many news websites.
Once created, the Quick Tabs blocks show up in your block listing, ready to be configured and enabled like other blocks.
Multiple Quick Tabs blocks can be placed on a single page.
Visit the Quick Tabs configuration page to choose a style for your Quick Tabs blocks.
Click on the "New QT block" tab below to get started.
', array('@configuration' => url('admin/settings/quicktabs'))); case 'admin/build/quicktabs/add': return ''. t('Here you can create a new Quick Tabs block. Once you have created this block you will be taken to the blocks page to configure and enable it.', array('@overview' => url('admin/build/block'))) .'
'; } } function quicktabs_theme() { return array( 'quicktabs_settings' => array( 'arguments' => array('form' => NULL), ), 'quicktabs_preview_page' => array( 'arguments' => array(), ), 'qt_tabs' => array( 'arguments' => array('form' => NULL), ), 'qtaj_tabs' => array( 'arguments' => array('form' => NULL), ), 'quicktabs_block' => array( 'arguments' => array('block', 'title' => TRUE), ), 'quicktabs_tabs' => array( 'arguments' => array('tabs'), ), ); } /** * Implementation of hook_menu(). */ function quicktabs_menu() { $items = array(); $items['admin/build/quicktabs'] = array( 'title' => 'Quick Tabs', 'description' => 'Create blocks of tabbed content - content for each tab can be a view or a block', 'page callback' => 'quicktabs_list', 'access arguments' => array('administer quicktabs blocks'), ); $items['admin/build/quicktabs/list'] = array( 'title' => 'List', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); $items['admin/build/quicktabs/add'] = array( 'title' => 'New QT block', 'access arguments' => array('create quicktabs block'), 'page callback' => 'quicktabs_new', 'weight' => 0, 'type' => MENU_LOCAL_TASK); $items['admin/build/quicktabs/ajax/add'] = array( 'title' => 'New QT AJAX block', 'access arguments' => array('create quicktabs block'), 'page callback' => 'quicktabs_new', 'page arguments' => array(TRUE), 'weight' => 1, 'type' => MENU_LOCAL_TASK); $items['admin/build/quicktabs/delete'] = array( 'title' => 'Delete QT block', 'access arguments' => array('administer blocks'), 'page callback' => 'drupal_get_form', 'page arguments' => array('quicktabs_block_delete'), 'type' => MENU_CALLBACK); $items['admin/build/quicktabs/edit'] = array( 'title' => 'Edit QT block', 'access arguments' => array('administer blocks'), 'page callback' => 'quicktabs_block_edit', 'type' => MENU_CALLBACK); $items['admin/settings/quicktabs'] = array( 'title' => 'Quick Tabs', 'description' => 'Select a style for your Quick Tabs blocks', 'page callback' => 'drupal_get_form', 'page arguments' => array('quicktabs_settings'), 'type' => MENU_NORMAL_ITEM, 'access arguments' => array('administer site configuration'), ); $items['quicktabs/preview'] = array( 'page callback' => 'quicktabs_preview_page', 'type' => MENU_CALLBACK, 'access arguments' => array('administer site configuration'), ); $items['quicktabs/ahah'] = array( 'page callback' => 'quicktabs_ahah', 'type' => MENU_CALLBACK, 'access arguments' => array('administer site configuration'), ); $items['quicktabs/views/displays'] = array( 'page callback' => 'quicktabs_ajax', 'type' => MENU_CALLBACK, 'access arguments' => array('administer site configuration'), ); $items['quicktabs/ajax/views'] = array( 'page callback' => 'quicktabs_ajax_views', 'type' => MENU_CALLBACK, 'access arguments' => array('access content'), ); $items['quicktabs/ajax/node'] = array( 'page callback' => 'quicktabs_ajax_node', 'type' => MENU_CALLBACK, 'access arguments' => array('access content'), ); return $items; } /** * Implementation of hook_perm(). */ function quicktabs_perm() { return array('create quicktabs block', 'administer quicktabs blocks'); } function quicktabs_list() { $result = db_query('SELECT qtid, title FROM {quicktabs}'); $header = array(t('Quick Tabs Block Name'), t('Delete')); $rows = array(); while ($row = db_fetch_object($result)) { $tablerow = array( array('data' => $row->title .' ('. l('edit', 'admin/build/quicktabs/edit/'. $row->qtid) .')'), array('data' => l(t('Delete'), 'admin/build/quicktabs/delete/'. $row->qtid)), ); $rows[] = $tablerow; } $output = theme('table', $header, $rows, array('id' => 'quicktabs')); return $output; } function quicktabs_new($ajax = FALSE) { global $base_url; $quicktabsForm = array( 'ajax_path' => $base_url .'/quicktabs/views/displays' ); drupal_add_js('/misc/jquery.form.js'); drupal_add_js(array('quicktabsForm' => $quicktabsForm), 'setting'); drupal_add_js(drupal_get_path('module', 'quicktabs') .'/js/quicktabs_form.js'); drupal_add_css(drupal_get_path('module', 'quicktabs') .'/quicktabs.css'); if (!$ajax) { return drupal_get_form('quicktabs_form'); } else { return drupal_get_form('quicktabs_aj_form'); } } function _quicktabs_get_default_views() { views_include('view'); views_include_default_views(); $defaults = module_invoke_all('views_default_views'); $views = array(); foreach ($defaults as $name => $view) { // Only views with a sufficiently high api version are eligible. if (isset($view->api_version) && $view->api_version >= 2) { $views[$name] = $view; } } return $views; } function _quicktabs_get_default_views_names() { $views = array(); foreach (_quicktabs_get_default_views() as $name => $view) { $views[] = array( 'name' => $name, ); } return $views; } function _quicktabs_get_default_view_displays($selected_view) { $displays = array(); foreach (_quicktabs_get_default_views() as $name => $view) { if ($name == $selected_view) { $display_array = $view->display; foreach ($display_array as $key => $display) { $displays[$key] = $key; } break; } } return $displays; } function quicktabs_get_views() { $result = db_query("SELECT v.name, v.description FROM {views_view} v"); $views = array(); while ($view = db_fetch_object($result)) { $views[$view->name] = $view->name; } $status = variable_get('views_defaults', array()); foreach (_quicktabs_get_default_views_names() as $view) { // Determine if default view is enabled or disabled. if (isset($status[$view['name']])) { $view['disabled'] = $status[$view['name']]; } if (empty($views[$view['name']]) && $view['disabled'] != 1) { $views[$view['name']] = $view['name']; } } return $views; } function quicktabs_get_blocks() { $blocks = _block_rehash(); $blocksarray = array(); foreach ($blocks as $i => $block) { if ($block['module'] != 'quicktabs') { $key = $block['module'] .'_delta_'. $block['delta']; $blocksarray[$key] = $block['info']; } } return $blocksarray; } function quicktabs_get_nodes() { $nodes = array(); // TODO: make the allowed node types an admin setting $result = db_query('SELECT nid, title FROM {node} WHERE type in ("page", "story")'); while ($row = db_fetch_object($result)) { $key = $row->nid; $nodes[$key] = $row->title; } return $nodes; } function quicktabs_form(&$form, $form_state = NULL) { $form = array( '#cache' => TRUE, ); $form['title'] = array( '#title' => t('Block Title'), '#type' => 'textfield', '#description' => t('The title of the whole block'), '#default_value' => ($form_state['values']['title'] ? $form_state['values']['title'] : ''), '#weight' => -5 ); $formtype = $form_state['values']['formtype']; if ($formtype == 'edit') { $tabcontent = $form_state['values']['tabs']; $form['qtid'] = array( '#type' => 'hidden', '#value' => $form_state['values']['qtid'] ); } if (isset($form_state['qt_count'])) { $qt_count = $form_state['qt_count']; } else { $qt_count = max(2, empty($tabcontent) ? 2 : count($tabcontent)); } // Add a wrapper for the tabs and Add Another Tab button. $form['qt_wrapper'] = array( '#tree' => FALSE, '#weight' => -4, '#prefix' => '