How to Programmatically Create a Quicktab Block in Drupal

3899114449 ec210c67d5 m

How to Programmatically Create a Quicktab Block in Drupal

We often run across parts of Drupal that are not yet exportable using a tool like features. Quicktabs is one such part. It's a neat module for a lot of Drupal sitebuilders to use. Quicktabs allows a sitebuilder to create tabbed displays of Drupal content from sources like views, blocks and nodes. Unfortunately, it is not exportable like views, boxes and content types. However, you can programmatically create Drupal quicktab blocks using hook_block by creating a $quicktab array and pass it to theme_quicktabs(). Use the code bellow to create your quicktab array. function mymodule_block($op = 'list', $delta = 0, $edit = array()) { switch($op) { case 'list': $blocks['mymodule_quicktabs'] = array('info' => t('[mymodule] Quicktabs')); return $blocks; break; case 'view': switch ($delta) { case 'mymodule_quicktabs': //set tab content $tabs['tabcontent'] = array( 'title' => t('Tab 1'), 'type' => 'freetext', 'text' => t('Free Text'), ); $quicktabs['qtid'] = 'mymodule_quicktabs'; $quicktabs['tabs'] = $tabs; $quicktabs['style'] = 'Zen'; $quicktabs['ajax'] = FALSE; $block = array('subject' => '', 'content' => theme('quicktabs', $quicktabs)); return $block; break; } } }

Related Posts

How to display an RSS feed in a Drupal block

Kristin Brinner
Read more

Loving the Block Revisited

Randall Knutson
Read more

If you aren't using Entity API to create nodes, you are doing it wrong

Randall Knutson
Read more

Drupal Tutorial: Use Views to Create an Alphabetical List of Taxonomy Terms

Kristin Brinner
Read more

Facet Block - The Unknown Hero

Kyle Taylor
Read more

Using Drupal 7 Entity Reference to help Create User Dashboards

Brent Bice
Read more