When first looking at the workings of this mod, I had in mind allowing individualized middlebox control, though I would have done it by defines rather than admin settings. I didn't pursue it at that time.
With this challenge, I have poked into admin configuration settings for the first time (learning something about how they work along the way), and have a package of alterations that I think will do the job when applied in full to the files.
install_middleboxes.sql ```php
//install_middleboxes.sql
SET @mid4=0;
SELECT (@mid4:=configuration_group_id) as mid4
FROM configuration_group
WHERE configuration_group_title= 'Editable Centerboxes';
DELETE FROM configuration WHERE configuration_group_id = @mid4;
DELETE FROM configuration_group WHERE configuration_group_id = @mid4;
INSERT INTO configuration_group VALUES (NULL, 'Editable Centerboxes', 'Settings for Editable Centerboxes', '100', '1');
UPDATE configuration_group SET sort_order = last_insert_id() WHERE configuration_group_id = last_insert_id();
SET @mid4=0;
SELECT (@mid4:=configuration_group_id) as mid4
FROM configuration_group
WHERE configuration_group_title= 'Editable Centerboxes';
/MIDDLEBOX_QTY becomes obsolete/
/INSERT INTO configuration VALUES (NULL, 'Middleboxes - Number to Display', 'MIDDLEBOX_QTY', '3', 'Define the number of middleboxes to display. The module comes with 9 middleboxes.', @mid4, 49, now(), now(), NULL, 'zen_cfg_select_option(array(''1'', ''2'', ''3'', ''4'', ''5'', ''6'', ''7'', ''8'', ''9''), ');
INSERT INTO configuration VALUES (NULL, 'Middleboxes - Position', 'MIDDLEBOX_POSITION', '0', 'Positioning options for the middleboxes.<br /><br /> 0=Off<br /><br />Above or Below the <strong>Main Page Define</strong> content.<br /><small><em>If the Main Page Define content is set to not display, the Above or Below Main Page Define options yield the same result.</em></small><br />1=Above Main Page Define content<br />2=Below Main Page Define content<br />3=Below <em>New, Specials, Featured</em> etc. centerboxes<br /><br />If you set <strong>Categories - Always Show on Main Page</strong> to <strong>Yes</strong>. <br /><small><em>If the Main Page Define content is set to not display, the Above or Below Main Page Define options yield the same result.</em></small><br />4=Above Main Page Define content and Categories<br />5=Between Main Page Define content and Categories<br />6=Below Categories<br />7=Below Categories and <em>New, Specials, Featured</em> etc. centerboxes', @mid4, 49, now(), now(), NULL, 'zen_cfg_select_option(array(''0'', ''1'', ''2'', ''3'', ''4'', ''5'', ''6'', ''7''), ');/
/allow middleboxes on internal category listings if desired/
INSERT INTO configuration VALUES (NULL, 'Middleboxes - Homepage Only?', 'MIDDLEBOX_HOME', '1', 'Display middleboxes on homepage only, or allow to display on internal categories pages?', @mid4, 49, now(), now(), NULL, 'zen_cfg_select_option(array(''0'', ''1''), ');
INSERT INTO configuration VALUES (NULL, 'Middlebox 1 - Position', 'MIDDLEBOX_NUMBER_1', '0', 'Location to display middlebox 1.<br /><br /> 0=Off<br /><br />Above or Below the <strong>Main Page Define</strong> content.<br /><small><em>If the Main Page Define content is set to not display, the Above or Below Main Page Define options yield the same result.</em></small><br />1=Above Main Page Define content<br />2=Below Main Page Define content<br />3=Below <em>New, Specials, Featured</em> etc. centerboxes<br /><br />If you set <strong>Categories - Always Show on Main Page</strong> to <strong>Yes</strong>. <br /><small><em>If the Main Page Define content is set to not display, the Above or Below Main Page Define options yield the same result.</em></small><br />4=Above Main Page Define content and Categories<br />5=Between Main Page Define content and Categories<br />6=Below Categories<br />7=Below Categories and <em>New, Specials, Featured</em> etc. centerboxes', @mid4, 49, now(), now(), NULL, 'zen_cfg_select_option(array(''0'', ''1'', ''2'', ''3'', ''4'', ''5'', ''6'', ''7''), ');
INSERT INTO configuration VALUES (NULL, 'Middlebox 2 - Position', 'MIDDLEBOX_NUMBER_2', '0', 'Location to display middlebox 2.<br /><br /> 0=Off<br /><br />Above or Below the <strong>Main Page Define</strong> content.<br /><small><em>If the Main Page Define content is set to not display, the Above or Below Main Page Define options yield the same result.</em></small><br />1=Above Main Page Define content<br />2=Below Main Page Define content<br />3=Below <em>New, Specials, Featured</em> etc. centerboxes<br /><br />If you set <strong>Categories - Always Show on Main Page</strong> to <strong>Yes</strong>. <br /><small><em>If the Main Page Define content is set to not display, the Above or Below Main Page Define options yield the same result.</em></small><br />4=Above Main Page Define content and Categories<br />5=Between Main Page Define content and Categories<br />6=Below Categories<br />7=Below Categories and <em>New, Specials, Featured</em> etc. centerboxes', @mid4, 49, now(), now(), NULL, 'zen_cfg_select_option(array(''0'', ''1'', ''2'', ''3'', ''4'', ''5'', ''6'', ''7''), ');
/repeat for 9 middleboxes/
tpl_index_default.php and tpl_index_categories.php ```php
<?php
//test 20120109 - code for tpl_index_default.php and tpl_index_categories.php
//replicate for each location changing == 1 to == 2 etc.
if($this_is_home_page or !MIDDLEBOX_HOME) {//only in tpl_index_categories.php
if (isset($middleboxes_group)) unset $middleboxes_group;
for ($i=1; $i<=9; $i++) {
if (constant('MIDDLEBOX_NUMBER_' . $i) == 1) $middleboxes_group[] = $i;
}
if (isset($middleboxes_group)) {?>
<!-- Begin Main Page Middleboxes Above Main Page Define -->
<?php
require($template->get_template_dir('tpl_middlebox_controller.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_middlebox_controller.php');
?>
<!-- End Main Page Middleboxes Above Main Page Define -->
<?php }
}//only in tpl_index_categories.php
//test ?>
<?php if (MIDDLEBOX_POSITION == 1) {//original code for tpl_index_default.php and tpl_index_categories.php ?>
<!-- Begin Main Page Middleboxes Above Main Page Define -->
<?php
if($this_is_home_page) require($template->get_template_dir('tpl_middlebox_controller.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_middlebox_controller.php');
?>
<!-- End Main Page Middleboxes Above Main Page Define -->
<?php } ?>
/includes/templates/your_template/templates/tpl_middlebox_controller.php ```php
<?php /*
* /includes/templates/your_template/templates/tpl_middlebox_controller.php test gjh42 2010-09-20 20120109
*/
?>
<div class="navColumnMiddleWrapper">
<?php
for($i=1; $i<=sizeof($middleboxes_group); $i++) {
$box_no = $middleboxes_group[$i];
?>
<div class="middleBoxContainer" id="middlebox_<?php echo $box_no; ?>">
<h2 class="middleBoxHeading" id="middlebox<?php echo $box_no; ?>Heading"><?php echo constant('BOX_HEADING_MIDDLEBOX' . $box_no); ?></h2>
<div class="middleBoxContent" id="middlebox<?php echo $box_no; ?>Content">
<?php require zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', constant('FILENAME_DEFINE_MIDDLEBOX_' . $box_no), 'false');?>
</div></div>
<?php
}//for ?>
</div>
<br class="clearBoth" />
```
```php
<?php
// in tpl_middlebox_x_default.php, the heading should not be <h1> which will already be on the page,
// but <h2> or <h3> like stock centerboxes
?>
<h1 id='middlebox_1-heading'><?php echo HEADING_TITLE; ?></h1>
<?php /*
* /includes/templates/your_template/templates/tpl_middlebox_controller.php test gjh42 2010-09-20 20120109
*/
?>
``` To be honest, I am not clear on the relationship between tpl_middlebox_controller.php and tpl_middlebox_x_default.php, as they appear to produce duplicate content. Are the tpl_middlebox_x_default.php files actually ever active?