Then it would seem to be a valuable feature to add the ability to select positions independently:)
I haven't looked at the controlling code myself to know how big of a job that would be.
Then it would seem to be a valuable feature to add the ability to select positions independently:)
I haven't looked at the controlling code myself to know how big of a job that would be.
My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.
Hmm... I had forgotten exactly which part of the code I had had a hand in:) Well then, I suppose I can have a look at it when I get time and see what it would involve. I didn't have anything to do with admin files, though.
My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.
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.sqltpl_index_default.php and tpl_index_categories.phpPHP Code:
//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*/
/includes/templates/your_template/templates/tpl_middlebox_controller.phpPHP Code:<?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 } ?>PHP Code:<?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" />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?PHP Code:<?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
*/
?>
Last edited by gjh42; 10 Jan 2012 at 04:13 AM.
This will allow each of nine middleboxes to be activated for one of the seven page positions. If 'Middleboxes - Homepage Only?' is set to 0, positions 4 through 7 would be able to display on internal category listing pages (useful when tpl_index_default is active on the homepage).
The middleboxes active in each position will display in numeric order within that section.
This line and its closing } are only needed in tpl_index_categories.php, since tpl_index_default.php is never used elsewhere than the homepage.
I have not tested this code, so I would appreciate feedback on how it works when put into the files (and if it doesn't work, we can work on debugging:). Look over the SQL carefully, as I'm not sure I understand it well enough to have edited it correctly.PHP Code:if($this_is_home_page or !MIDDLEBOX_HOME) {//only in tpl_index_categories.php
Something that needs to be confirmed by testing isFor the first position, testing for a value == 1 might give misleading results, as simply being set can be interpreted by PHP as '1' or true. If it is 0, it should evaluate to false and not trigger for position 1. Just in case this fails, you could change that one test to === 1 (or maybe === '1' ) (precisely 1, not just "evaluates to 1"). Other values would not have the possibility of ambiguity.PHP Code:if (constant('MIDDLEBOX_NUMBER_' . $i) == 1) $middleboxes_group[] = $i;
Noticed another mistake: This test needs to go from 0 to sizeof -1, as auto-indexed arrays start with item 0.PHP Code:for($i=1; $i<=sizeof($middleboxes_group); $i++) {
orPHP Code:for($i=0; $i<=sizeof($middleboxes_group)-1; $i++) {
PHP Code:for($i=0; $i<sizeof($middleboxes_group); $i++) {
Eyes crossing..If I have some spare time this weekend, I might be able to test this.. Got three sites I'm working on and a singing gig Saturday night to rehearse for.. So I've got a LOT on my plate.. But I'll do my best..
![]()
My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.
is there an update to this module so it can work with Zen cart 1.5 ?