1.首先,新建文件includes\modules\sideboxes\price_range.php
<?php function zen_count_products_in_price($pfrom, $pto) { global $db; if ((int)$pfrom >= 1) { $products_query = "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_price > " . $pfrom; if ($pto != \'∞\') { $products_query .= " and p.products_price <= ".$pto; } //echo $products_query . \'<br />\'; $products = $db->Execute($products_query); $products_count = $products->fields[\'total\']; } return (int)$products_count; } $price_array = array(); $price_array[] = array(\'pfrom\'=>1,\'pto\'=>300,\'counts\'=>zen_count_products_in_price(1,300)); $price_array[] = array(\'pfrom\'=>301,\'pto\'=>500,\'counts\'=>zen_count_products_in_price(301,500)); $price_array[] = array(\'pfrom\'=>501,\'pto\'=>1000,\'counts\'=>zen_count_products_in_price(501,1000)); $price_array[] = array(\'pfrom\'=>1001,\'pto\'=>2000,\'counts\'=>zen_count_products_in_price(1001,2000)); $price_array[] = array(\'pfrom\'=>2001,\'pto\'=>3000,\'counts\'=>zen_count_products_in_price(2001,3000)); $price_array[] = array(\'pfrom\'=>3001,\'pto\'=>4000,\'counts\'=>zen_count_products_in_price(3001,4000)); $price_array[] = array(\'pfrom\'=>4001,\'pto\'=>5000,\'counts\'=>zen_count_products_in_price(4001,5000)); $price_array[] = array(\'pfrom\'=>5001,\'pto\'=>\'∞\',\'counts\'=>zen_count_products_in_price(5001,\'all\')); $content = \'\'; $This_cPath = $cPath; $content .= \'<div id="\' . str_replace(\'_\', \'-\', $box_id . \'Content\') . \'" class="sideBoxContent">\' . "\n"; $content .= \'<ul>\'; $price_array_count = count($price_array); for($rr=0;$rr<$price_array_count;$rr++) { $content .= \'<li><a\'; if($price_array[$rr][\'pfrom\']==$_GET[\'pfrom\'] and $price_array[$rr][\'pto\']==$_GET[\'pto\']) { $content .= \' class="pricecurrent"\'; } $content .= \' href="index.php?main_page=advanced_search_result&search_in_description=1\'; if($_GET[\'categories_id\']) { echo \'&categories_id=\'.$This_cPath; } $content .= \'&inc_subcat=1&pfrom=\'.$price_array[$rr][\'pfrom\'].\'&pto=\'.$price_array[$rr][\'pto\'].\'" rel="nofollow">\'.$price_array[$rr][\'pfrom\']; if(!empty($price_array[$rr][\'pto\'])) { $content .= \' - \'.$price_array[$rr][\'pto\'].$GLOBALS[\'currencies\']->currencies[$_SESSION[\'currency\']][\'symbol_left\']; }else{ $content .= \' Up to...\'; } $content .= \'</a><span>(\'.$price_array[$rr][\'counts\'].\')</span></li>\'; } $content .= \'</ul>\'; $content .= \'</div>\'; $title = \'Price Range\'; require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,\'common\') . \'/\' . $column_box_default); ?>
2.用css代码美化前台显示
#pricerange a{ padding-left:15px; line-height:27px; font-size:12px; color:#666; background:url("../images/pricea.gif") no-repeat scroll 0 2px transparent; } #pricerange a:hover, #pricerange a.pricecurrent { color:#0075e2; text-decoration:none; background:url("../images/priceahover.gif") no-repeat scroll 0 2px transparent; } #pricerange ul, #pricerange ul li{ padding:0; margin:0; } #pricerange ul li { border-bottom: 1px dashed #ccc; line-height: 23px; list-style-type: none; text-indent: 12px; font-size:12px; } #pricerange ul li span { color: #999999; display: inline; font: 10px Arial; padding-left:2px; }
附:css样式图片
3.后台开启边框价格筛选插件。