Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   New Versions, & Updating (http://forum.bytesforall.com/forumdisplay.php?f=12)
-   -   [SOLVED] Change the cell width in new widget area (http://forum.bytesforall.com/showthread.php?t=2461)

duping812 Jul 15, 2009 09:30 PM

[SOLVED] Change the cell width in new widget area
 
Thanks Flynn for the great update on the new widget function, now I can create my page menu bar and
feed subscribe icons in the same line.

This is what I defined for the new widget in header,
PHP Code:

<?php bfa_widget_area('name=myheader&cells=2&align_1=9&width_1=800&align_2=3&width_2=250'); ?>

The first cell I use PixoPoint Multi-level Navigation Plugin to create stylish menus, and the second cell to place feed subscribe icons. But the width parameters of two cells are not pass to the final code, they equal to half of the maximum width 1050.

You can check the result at my blog, http://thdp.org/
Could you tell me what's wrong with this?

Thanks,

Flynn Jul 16, 2009 10:46 AM

A bug, thanks. To correct it in 3.4.2, replace the whole bfa_widget_area function from line 308-362 in functions.php with this:

This adds the width parameter which was missing, adds the missing <tr> ... </tr>, and displays a <DIV> instead of a table, if there's only 1 widget cell.

PHP Code:

function bfa_widget_area($args '') {
    
$defaults = array(
        
'cells' => 1,
        
'align' => 2,
        
'before_widget' => '<div id="%1$s" class="widget %2$s">',
        
'after_widget' => '</div>',
        
'before_title' => '<div class="widget-title"><h3>',
        
'after_title' => '</h3></div>',
    );
    
    
$r wp_parse_args$args$defaults );
    
extract$rEXTR_SKIP );

    
$area_id strtolower(str_ireplace(" ""_"$r['name']));
    
    
// If there are more than 1 cell, use a table, otherwise just a DIV:
    
if ( $r['cells'] > ) {
    
        echo 
'<table id="' $area_id '" class="bfa_widget_area" style="table-layout:fixed;width:100%" cellpadding="0" cellspacing="0" border="0">';

        
// If a width was set for any of the widget area cells:
        
if ( strpos($args,'width_') !== FALSE ) {
            echo 
"\n<colgroup>";
            for ( 
$i 1$i <= $r['cells']; $i++ ) {
                echo 
'<col';
                
$current_width "width_" $i;
                if ( 
$r[$current_width] ) {
                    echo 
' style="width:' $r[$current_width] . 'px"';
                }
                echo 
' />';
            }
            echo 
"</colgroup>";
        }
        
        echo 
"<tr>";
        
        for ( 
$i 1$i <= $r['cells']; $i++ ) {
            
                
$current_name $r['name'] . ' ' $i;
                
$current_id $area_id '_' $i;
                
$current_align "align_" $i;
                
                echo 
"\n" '<td id="' $current_id .'" ';
                
                if ( 
$r[$current_align] ) { 
                    
$align_type $r["$current_align"];
                } else {
                    
$align_type $r['align'];
                }
                
                echo 
bfa_table_cell_align($align_type) . ">";
                
                
// Register widget area
                #$bfa_ata_widget_areas[] = $current_name; 
                  
$bfa_ata_widget_areas[] = array(
                      
"name" => $current_name,
                      
"before_widget" => $r['before_widget'],
                      
"after_widget" => $r['after_widget'],
                      
"before_title" => $r['before_title'],
                      
"after_title" => $r['after_title']
                      );
          
                   
// Display widget area
                
dynamic_sidebar("$current_name"); 
                
                echo 
"\n</td>";
            
        }
        
        echo 
"\n</tr></table>";     
    
    } else {
    
        
// If only 1 widget cell, use a DIV instead of a table
        
echo '<div id="' $area_id '" class="bfa_widget_area">';
        
        
// Add new widget area to existing ones
        
$bfa_ata_widget_areas[] = array(
            
"name" => $r['name'],
            
"before_widget" => $r['before_widget'],
            
"after_widget" => $r['after_widget'],
            
"before_title" => $r['before_title'],
            
"after_title" => $r['after_title']
            );

        
// Display widget area
        
dynamic_sidebar($r['name']);     

        echo 
'</div>';
    
    }
    
    
update_option("bfa_widget_areas"$bfa_ata_widget_areas);



Additionally add this at HTML/CSS Inserts:

HTML Code:

table.bfa_widget_area td {
text-align: left;
}

Otherwise the text inside widgets will be centered, if the widget cell is centered


All of the above will be included in 3.4.3

duping812 Jul 16, 2009 07:19 PM

Thanks for a such reply.
Prob solved, not it works perfectly. I even included search form in the menu bar.


All times are GMT -6. The time now is 05:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.