Download & Extend

Using taxonomy based views in tabbed block

Project:Tabbed Block
Version:5.x-1.2
Component:Code
Category:support request
Priority:normal
Assigned:joetsuihk
Status:postponed (maintainer needs more info)
Issue tags:Newbie

Issue Summary

Hi, love the module. Unfortunately I am using views which use taxonomy as an argument therefore there will be times when the view and block are empty, which results in the error message in the tab. In this scenario I don't want the tabbed block at all. I have mucked around a bit and being both a drupal newbie and a convert from Coldfusion, my code or approach is not at all good, but perhaps it's useful.

The first thing is to loop through the tabs and see if $temp->content is set, totalling the number of tabs with content. The logic for this was copied from the view code. If the total is still 0, then return false; before the js and css are loaded (this prevents the ajax jscript running which leaves the refresh link even if I clear the tabs later on.

I pasted this code just below }else if( $op == "view" ){

//**SF Patch to not display empty tab block
    $tabs_with_content_count = 0;
    $settings = variable_get( 'tabbed_block_settings'.$module_delta , NULL);
    if ( $settings ){
foreach ( $settings as $conf ){
list( $name , $delta, $delta2) = explode( "-" , $conf );       
if ( !empty($delta2) ){
  $delta = $delta."-".$delta2;
}       
$temp = tabbed_block_output_content_block( array( 'module'=>$name , 'delta'=>$delta , 'override_title' => 0 , 'override_title_text' => '' ) );
if(isset($temp->content)) {
$tabs_with_content_count = $tabs_with_content_count +1;
}
if ($tabs_with_content_count == 0) {
return false;
}
}
    }
    // **SF End patch

My second patch I have been playing with is changing the two lines 142 and 143 which read

$tab_subject .= "<li><a href='#fragment".$module_delta."-".$i."' onclick='return(false);'>Error! click here!</a></li>";
$tab_content .= "<div id='fragment".$module_delta."-".$i."'>".l("Please config the tab title here." , "admin/build/block/configure/".$name."/".$delta)."</div>";

to

$tab_subject .='';
$tab_content .='';

which seems to remove the tab quite well (not fully tested). I hope these help I know the code is rubbish, but it will keep me going for a while but hopefully you will have a more elegant solution down the line.

Comments

#1

Assigned to:Anonymous» joetsuihk
Status:active» postponed (maintainer needs more info)

you mean just disable those tabs which content is empty?

let's see.
a design problem.