To control a sidebox and when it displays you are just needing to stop the code from running in the:
/includes/modules/sideboxes/blah_blah.php
/includes/templates/templates_default/sideboxes/blah_blah.php
file that has the code ...
I prefer to copy both peices of a sidebox to the overrides to avoid confusion on what is customized and what is not ...
/includes/modules/sideboxes/your_template_dir/blah_blah.php
/includes/templates/your_template_dir/sideboxes/blah_blah.php
To manage the control of the code, you customize the file:
/includes/modules/sideboxes/your_template_dir/blah_blah.php
For example, look at the
/includes/modules/sideboxes/tell_a_friend.php
code and how that is constructed:
Code:
// test if box should display
$show_tell_a_friend= false;
if (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) {
if (!($_GET['main_page']==FILENAME_TELL_A_FRIEND)) $show_tell_a_friend = true;
}
if ($show_tell_a_friend == true) {
require($template->get_template_dir('tpl_tell_a_friend.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_tell_a_friend.php');
$title = BOX_HEADING_TELL_A_FRIEND;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}
The IF statement has a variable $show_tell_a_friend which when true allows the code to run ... when false the code will not run and the sidebox is disabled, even though it is set to run in the Layout Boxes Controller ...
To manage any other sidebox, you do the same thing where you set a variable with a condition to set true or false and then use that variable to run the code or not ...
Many sideboxes already have a variable set as they have conditions as part of the original code ...
Those sideboxes that do not have a variable can, but simply adding the variable and the conditions to set it to true or false and then surrounding the code with an IF that lets the code run or not based on that condition ...
The categories sidebox:
/includes/modules/sideboxes/categories.php
has the code:
Code:
$main_category_tree = new category_tree;
$row = 0;
$box_categories_array = array();
// don't build a tree when no categories
$check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
if ($check_categories->RecordCount() > 0) {
$box_categories_array = $main_category_tree->zen_category_tree();
}
require($template->get_template_dir('tpl_categories.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_categories.php');
$title = BOX_HEADING_CATEGORIES;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
There isn't, by default, a variable set to control the condition of when to run this, so one needs to be added and the IF needs to be added to control the code ...
Code:
// test if box should display
$show_categories= false;
if (something_happens_here) {
// run the code
$show_categories= true;
} else {
// do not run the code
$show_categories= false;
}
if ($show_categories == true) {
$main_category_tree = new category_tree;
$row = 0;
$box_categories_array = array();
// don't build a tree when no categories
$check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
if ($check_categories->RecordCount() > 0) {
$box_categories_array = $main_category_tree->zen_category_tree();
}
require($template->get_template_dir('tpl_categories.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_categories.php');
$title = BOX_HEADING_CATEGORIES;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}
Again, follow the use of the templates and overrides to make life easier on future upgrades ...
Easy smeazy, eh?
Bookmarks