Let's say you want the sidebox
/includes/modules/sideboxes/whats_new.php
to only appear on the main page ...
Copy to your templates and overrides directory:
/includes/modules/sideboxes/your_templates_dir/whats_new.php
The original code looks like this:
// display limits
//$display_limit = zen_get_products_new_timelimit();
$display_limit = zen_get_new_date_range();
$random_whats_new_sidebox_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price
from " . TABLE_PRODUCTS . " p
where p.products_status = 1 " . $display_limit . "
limit " . MAX_RANDOM_SELECT_NEW;
$random_whats_new_sidebox_product = zen_random_select($random_whats_new_sidebox_product_query);
if ($random_whats_new_sidebox_product->RecordCount() > 0 ) {
$whats_new_price = zen_get_products_display_price($random_whats_new_sidebox_product->fields['products_id']);
$random_whats_new_sidebox_product->fields['products_name'] = zen_get_products_name($random_whats_new_sidebox_product->fields['products_id']);
$random_whats_new_sidebox_product->fields['specials_new_products_price'] = zen_get_products_special_price($random_whats_new_sidebox_product->fields['products_id']);
require($template->get_template_dir('tpl_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_whats_new.php');
$title = BOX_HEADING_WHATS_NEW;
$title_link = FILENAME_PRODUCTS_NEW;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}
Let's change it a bit ...
We want to add a condition for an IF statement to test should this show ...
Change the code to read:
// test if box should display
$show_whats_new= true;
// only show if the main page
if ($this_is_home_page == true) {
$show_whats_new= true;
} else {
$show_whats_new= false;
}
if ($show_whats_new == true) {
// display limits
//$display_limit = zen_get_products_new_timelimit();
$display_limit = zen_get_new_date_range();
$random_whats_new_sidebox_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price
from " . TABLE_PRODUCTS . " p
where p.products_status = 1 " . $display_limit . "
limit " . MAX_RANDOM_SELECT_NEW;
$random_whats_new_sidebox_product = zen_random_select($random_whats_new_sidebox_product_query);
if ($random_whats_new_sidebox_product->RecordCount() > 0 ) {
$whats_new_price = zen_get_products_display_price($random_whats_new_sidebox_product->fields['products_id']);
$random_whats_new_sidebox_product->fields['products_name'] = zen_get_products_name($random_whats_new_sidebox_product->fields['products_id']);
$random_whats_new_sidebox_product->fields['specials_new_products_price'] = zen_get_products_special_price($random_whats_new_sidebox_product->fields['products_id']);
require($template->get_template_dir('tpl_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_whats_new.php');
$title = BOX_HEADING_WHATS_NEW;
$title_link = FILENAME_PRODUCTS_NEW;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}
} // eof: test $show_whats_new
Now it will only show when the variable $this_is_home_page evaluates to true ...
Linda McGrath
If you have to think ... you haven't been zenned ...
**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!