Here are the following changes that I made to get the center position working for v1.9.4
/// denton: defined column widths (this may already be defined elsewhere in v1.9.4
/// but I did not end up finding out where
/// Bounds for block widths on this page
define('BLOCK_L_MIN_WIDTH', 120);
define('BLOCK_L_MAX_WIDTH', 120);
define('BLOCK_C_MIN_WIDTH', 400);
define('BLOCK_C_MAX_WIDTH', 600);
define('BLOCK_R_MIN_WIDTH', 120);
define('BLOCK_R_MAX_WIDTH', 120);
/// denton: added $preferred_width_center declaration to existing declarations for left and right
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
BLOCK_L_MAX_WIDTH);
$preferred_width_center = bounded_number(BLOCK_C_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_CENTER]),
BLOCK_C_MAX_WIDTH);
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
BLOCK_R_MAX_WIDTH);
/// aartiles: Added a center blocks position
if (blocks_have_content($pageblocks, BLOCK_POS_CENTER) || $editing) {
//echo '<td style="width: '.$preferred_width_center.'px;" id="middle-column">';
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_CENTER);
//echo '</td>';
}
- /course/format/weeks/format.php (my changes were for Week view, similar changes will be needed if viewing by Topics)
/// denton: defined centre variables
$lmin = (empty($THEME->block_l_min_width)) ? 100 : $THEME->block_l_min_width;
$lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width;
$cmin = (empty($THEME->block_c_min_width)) ? 400 : $THEME->block_c_min_width;
$cmax = (empty($THEME->block_c_max_width)) ? 600 : $THEME->block_c_max_width;
$rmin = (empty($THEME->block_r_min_width)) ? 100 : $THEME->block_r_min_width;
$rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width;
/// denton: added BLOCK_C_MIN_WIDTH and BLOCK_C_MAX_WIDTH
define('BLOCK_L_MIN_WIDTH', $lmin);
define('BLOCK_L_MAX_WIDTH', $lmax);
define('BLOCK_C_MIN_WIDTH', $cmin);
define('BLOCK_C_MAX_WIDTH', $cmax);
define('BLOCK_R_MIN_WIDTH', $rmin);
define('BLOCK_R_MAX_WIDTH', $rmax);
/// denton: added $preferred_width_center
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
BLOCK_L_MAX_WIDTH);
$preferred_width_center = bounded_number(BLOCK_C_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_CENTER]),
BLOCK_C_MAX_WIDTH);
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
BLOCK_R_MAX_WIDTH);
/// aartiles: Added a center blocks position
/// denton: here's probably the trickiest part: depending on your theme, you may also want to call a custom divclass
/// (I've called it csl_class) to differentiate between sideblock (for left and right blocks) and the newly
/// created middleblock
/// I've also made changes to my CSS file, which is noted below
if (blocks_have_content($pageblocks, BLOCK_POS_CENTER) || $editing) {
echo '<div class = "csl_class">';
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_CENTER);
echo '</div>';
}
/// aartiles: New block position BLOCK_POS_CENTER
define('BLOCK_POS_CENTER', 'c');
/// aartiles: Added new block position BLOCK_POS_CENTER
function blocks_get_positions() {
return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT, BLOCK_POS_CENTER);
}
/// aartiles: Changes done for complain with a center blocks position
function blocks_move_position(&$instance, $move) {
if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
return BLOCK_POS_CENTER;
} else if($instance->position == BLOCK_POS_CENTER && $move == BLOCK_MOVE_RIGHT) {
return BLOCK_POS_RIGHT;
} else if ($instance->position == BLOCK_POS_CENTER && $move == BLOCK_MOVE_LEFT) {
return BLOCK_POS_LEFT;
} else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) { return BLOCK_POS_CENTER; } }
return $instance->position;
}
- /theme/theme_name/styles_color.css
/// denton: added the following lines to the end of my css document
/// don't forget to double check your widths and make sure that the right .header background
/// is also added
.csl_class .sideblock .header {
width: 490px;
}
.csl_class .sideblock .header .title {
background:transparent url(images/block_header_center.gif) no-repeat scroll center bottom;
min-height:26px;
text-align:center;
}
.csl_class .sideblock .content {
width: 490px;
}
.csl_class .sideblock .content .message {
text-align: center;
}
Notes:
I think I may have overdefined some of the center width variables, but I can't be bothered going back and checking.
To move your block, simply turn editing on and use the arrows!
Thanks again to Alfredo for doing all the hard bits.
Great patch Alfredo!
But, can I put the block in the bottom of the page? now the block is positioned at the top of the page...
Raül