Forums / Templates, Stylesheets, Page Layout / "Specials" sidebox showing only for certain categories?

"Specials" sidebox showing only for certain categories?

Views: 484

Results 1 to 3 of 3
8 Sep 2012, 7:07 PM
#1
kcb410 avatar

kcb410

Zen Follower

Join Date:
Dec 2008
Location:
Toronto
Posts:
348
Plugin Contributions:
0

"Specials" sidebox showing only for certain categories?

Hello Everyone,

I would like to create a 'Sales' sidebox that shows only when the customer is looking at products in a specified category. Is there an easy way to make this happen in Zen Cart? I searched for a plugin that would achieve this but I don't see one available.

Any comments or help would be appreciated.

We're using Zen 139h.

Thank you!

8 Sep 2012, 10:47 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: "Specials" sidebox showing only for certain categories?

First, copy /includes/templates/template_default/sideboxes/tpl_specials.php to /includes/templates/YOUR_TEMPLATE/sideboxes/tpl_specials.php and then edit the copied file to add the lines in red:

<?php
/**
 * Side Box Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_specials.php 18698 2011-05-04 14:50:06Z wilt $
 */
$specialCategories = 'list_all_categories_you_want_the_sidebox_displayed_on'; /* ... separated by commas, no intervening blanks */
if ($current_page_base == FILENAME_PRODUCT_INFO && in_array($cPath, explode(',', $specialCategories))) {
  $content = "";
  $content .= '<div class="sideBoxContent centeredContent">';
  $specials_box_counter = 0;
  while (!$random_specials_sidebox_product->EOF) {
    $specials_box_counter++;
    $specials_box_price = zen_get_products_display_price($random_specials_sidebox_product->fields['products_id']);
    $content .= "\n" . '  <div class="sideBoxContentItem">';
    $content .= '<a href="' . zen_href_link(zen_get_info_page($random_specials_sidebox_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_specials_sidebox_product->fields["master_categories_id"]) . '&products_id=' . $random_specials_sidebox_product->fields["products_id"]) . '">' . zen_image(DIR_WS_IMAGES . $random_specials_sidebox_product->fields['products_image'], $random_specials_sidebox_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
    $content .= '<br />' . $random_specials_sidebox_product->fields['products_name'] . '</a>';
    $content .= '<div>' . $specials_box_price . '</div>';
    $content .= '</div>';
    $random_specials_sidebox_product->MoveNextRandom();
  }
  $content .= '</div>' . "\n";
}
9 Sep 2012, 12:25 AM
#3
kcb410 avatar

kcb410

Zen Follower

Join Date:
Dec 2008
Location:
Toronto
Posts:
348
Plugin Contributions:
0

Re: "Specials" sidebox showing only for certain categories?

Thanks Lat9....I'll give this a try on Monday!