could something like this http://drupal.org/node/640598 be done for block-tabs too?
if a block (being filled with data dynamically) returns no data the tab get's hidden?
would be great!

Comments

pasqualle’s picture

Category: feature » support

Hide empty tab works for any tab type, but the tab content must be really empty..
example:
'' <- this is empty string
'<div></div>' or '&nbsp;' seems like empty, as nothing is displayed but it is not an empty string..

thommyboy’s picture

Hi,
that's what I hoped. But I do have an empty Block, no title, no body and still the Tab appears.
When using Views everything works fine...
I have to add that my block isn't a Views-block! It's just a manually set up block- maybe that's the problem?
Regards
Thomas

crystaldawn’s picture

Category: support » bug
Status: Active » Needs work

This is actually a bug in the module itself. I had this same exact problem. The problem is the way that it checks for an empty tab. Instead of checking whats actually in the DB, it instead checks the $contents variable which is the improper way to do this. It should be checking values in the db and not contents that could come from other modules (such as CCK fields). I was able to fix this by using the parsing_api module and putting this in the quicktabs.module file in the quicktabs_render() function on line 185. This is NOT the correct way to fix this problem, but it does show how to solve it if you just want it to work with the least amount of code tinkering. Again this is not the proper fix, but for my situation it worked just fine since all of my tabs that were showing up when empty were CCK fields.

/**
 * Render quicktabs.
 */
function quicktabs_render($quicktabs) {
  // convert views arguments to an array, retrieving %-style args from url
  $quicktabs['tabs'] = _quicktabs_prepare_views_args($quicktabs['tabs']);

  if ($quicktabs['hide_empty_tabs'] && !$quicktabs['ajax']) {
    // Remove empty tabpgages.
    foreach ($quicktabs['tabs'] as $key => $tab) {
      $contents = quicktabs_render_tabpage($tab, TRUE);
if (empty($contents)
//This next line checks for contents that is empty and trims out stuff from CCK.  This should be changed, we dont want to have to require parsing_api as a dependency for a bug like this.
//If there is data after the div statement AND there is nothing between the tags, then this is an empty CCK field!
 || (after('<div class="field-content">', $contents, FALSE) && !between('<div class="field-content">', '</div>', $contents, FALSE)) 
) {
        unset($quicktabs['tabs'][$key]);
      }
gateway69’s picture

hmm im having this issue, where i have 2 views with arguments, when a tab has no data in it , the div tags still show up and cause the tab to render still.. not sure how I can get around this, I put your code in as well and I get the same thing?

<div class="view-content">
      <table class="views-view-grid">
  <tbody>
                <tr class="row-1 row-first row-last">
                  <td class="col-1">
                      </td>
                  <td class="col-2">
                      </td>
                  <td class="col-3">
                      </td>
                  <td class="col-4">
                      </td>
              </tr>
      </tbody>
</table>
    </div>
      <table class="views-view-grid">
  <tbody>
                <tr class="row-1 row-first row-last">
                  <td class="col-1">
                      </td>
                  <td class="col-2">
                      </td>
                  <td class="col-3">
                      </td>
                  <td class="col-4">
                      </td>
              </tr>
      </tbody>
</table>
    
katbailey’s picture

Status: Needs work » Closed (works as designed)

I really don't see this as a Quicktabs bug - a decent patch might convince me otherwise, but in the meantime I'm closing this issue.

Binu Varghese’s picture

Issue summary: View changes

First off, after you create a quick tab instance, select the the option to "Hide empty tabs" (Make sure the ajax mode is not set).

Now, if the view is truly empty, the tab will gracefully disappear from the tabs. But, how to ensure that the views output is truly empty?

- Simply add a views "filter" setup for the entity you are trying to display set to "Is not empty (NOT NULL)".

Cheers!