0

I want to add horizontal tabs (not vertical tabs as shown in examples) as shown on the site : http://www.nseindia.com/ (Get Quotes on the top). I tried using menu modules like superfish and nice menu's it didn't solve my purpose.

I want to add this form with tabs via code and this is what I'm using for adding form to my block:

/**
 * Create the form.
 */
function getQuotes_search_block_form($form, &$form_state) {
  $form['keys'] = array(
    '#type' => 'textfield',
    '#title' => 'Get Quotes',
    '#default_value' => t('Enter Script name/Code /ID'),
    '#size' => 35,
    '#maxlength'=> 255,
    '#attributes' => array(
         'onblur' => "if (this.value == '') {this.value = 'Enter Script name/Code /ID'}",
         'onfocus' => "if (this.value == 'Enter Script name/Code /ID') {this.value = ''}",
         ),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Search',
    '#states' => array(
         'visible' => array(
            'input[name="keys"]' => array('filled' => TRUE),
          ),
    ),
  );
  return $form;
}

/**
 * Create the form submit handler.
 */
function getQuotes_search_block_form_submit($form, &$form_state) {
  $id = $form_state['values']['keys'];
  if ($id && $id != 'Enter Script name/Code /ID') {
    drupal_set_message(t('The form has been submitted'));
    drupal_goto('custom/node/search/' . $form_state['values']['keys']);
  }
}

/**
 * Create the search results menu callback.
 */
function mymodule_menu() {
  $items['custom/node/search/%'] = array(
    'page callback' => 'mymodule_do_search',
    'page arguments' => array(3),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Create the search results callback function.
 */
function getQuotes_do_search($keys) {
  // set the page title
  drupal_set_title('FAQ search results');
  // get the search results
  $results = module_invoke('node', 'search_execute', $keys . " type:faq");
  return theme('search_results', array('results' => $results));
}


/**
 * Create the search form block.
 */
function getQuotes_block_info() {
  $blocks['faq_search'] = array(
    'info' => t('FAQ Search Block'),
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}

function getQuotes_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'faq_search':
      $block['title'] = 'Custom FAQ Search';
      $block['content'] = drupal_render(drupal_get_form('getQuotes_search_block_form'));
      break;
  }
  return $block;
}

How do I add the horizontal tabs?

1 Answer 1

3

You don't say what you want in the other tabs but if you want tabbed blocks I would recommend using the quicktabs module.

It will allow you to create a quicktabs block that contains your custom block as one tab, and any other block/view/node in other tabs.

It will be far easier than making it custom. It is a very widely used and stable module.

1
  • this looks good, as long as I can get the callback functions working. Commented Jul 8, 2013 at 1:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.