Embedding Multiple Views and Creating Panel-Like Pages in Quick Tabs
You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules
In looking for a way to create quick tab content that emulated panels-like content, I had first created a node and using the php input filter, embedded views using views_embed_view(). This however was a major performance concern, as the php input filter is not cached, and stores the php in the database, using eval() to process it on node load.
A better solution is to create a custom block using hook_block, and store the block content in an include file. You can then set these blocks as your Quick Tab content.
Step 1
We need to add our block(s) to a module. I just added them to my site's custom module, mysite_custom. In your module, use the following code:
function mysite_custom_block($op = 'list', $delta = 0, $edit = array()) {
if ($op == 'list') {
$blocks[0] = array(
'info' => t('My Quicktab'),
'cache' => BLOCK_CACHE_GLOBAL, // You may want to change this setting. See http://api.drupal.org
);
return $blocks;
}
else if ($op == 'view') {
switch($delta) {
case 0:
require_once('mysite_custom.qtpages.inc');
$block = array(
'subject' => 'My Quicktab',
'content' => mysite_custom_qtabs_1(),
);
break;
}
return $block;
}
}
Make sure you change "mysite_custom" to whatever your module is called. We're going to put our block content in an include file for optimum performance.
Step 2
Create a file called "mysite_custom.qtpages.inc"
In this file, here's the code to display our content.
function mysite_custom_qtabs_1() {
$output =
'<p>Some custom content goes here.</p>
<div class="column-1">
<h2>News</h2>' .
views_embed_view('homepage_today', 'block_1') .
'</div>
<div class="column-2">
<h2>Events</h2>' .
views_embed_view('homepage_events', 'block_1') .
'</div>';
return $output;
}
This is of course just an example layout.
Step 3
In your Quick Tab settings, choose the block "My Quicktab" we created and you're off to the races.
I have three Quick Tabs using blocks all generated this way, and it is smoking fast and drastically reduces resource consumption.
Good luck!
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion