0

I have programmatically created a quicktab but the contents of the tab do not display. I have followed the instructions and have looked at this related question but it does not work for me. I suspect I must be missing something simple. Here is the code for creating the quicktab:

function create_quicktabs() {

  $block_ids = array(
    'Books & Journals' => 'books_journals_search',
    'Articles' => 'articles_search',
    'Archives' => 'archives_search',
    'Databases' => 'databases_search',
    'Course Reserves' => 'course_reserves_search',
    'Institution Repository' => 'repository_search',
  );

  $tabs = array();
  foreach ($block_ids as $title => $block_delta) {
    $block = block_load('catalogue_search', $block_delta);
    $tabs[] = array(
      'title' => t($title),
      'type' => 'block',
      'bid' => $block->bid,
      'hide_title' => TRUE,
    );
  }

  // Configure the QuickTabs options
  $quicktabs_options = array(
    'style' => 'Bullets',
    'ajax' => FALSE,
    'sorted' => FALSE,
  );

  $quicktabs_name = 'catalogue_search';
  $quicktabs = quicktabs_build_quicktabs($quicktabs_name, $quicktabs_options, $tabs);
  return $quicktabs;
}

I get no errors when this is run, but it seems as though quicktabs can't find the block to display. I have verified that the blocks do exist and the block ids are valid. I have also tried using block_delta for the bid value - again same result. This is for Drupal 7 by the way. What am I doing wrong?

1 Answer 1

0

I have found the solution to the problem through some experimentation. It appears that the value for bid must take the form of: module_name_delta_block_delta. To illustrate this, here is an example:

$tabs[] = array(
  'title' => t($title),
  'type' => 'block',
  'bid' => 'catalogue_search_delta_books_journals_search',
  'hide_title' => TRUE,
);

The module name is: catalogue_search. Then you need the text: delta Finally the block delta name: books_journals_search.

I did not see this documented anywhere so hopefully this will help others with the same problem.

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.