zoukankan      html  css  js  c++  java
  • zencart价格筛选插件

    1.首先,新建文件includesmodulessideboxesprice_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">' . "
    ";
    $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 .= '&nbsp;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.后台开启边框价格筛选插件。

  • 相关阅读:
    学习记录
    cxf client端借口类型找不到问题
    zookeeper dubbo 问题解决录
    unkow jdbc driver : http://maven.apache.org
    推荐eclipse插件Properties Editor
    WPS for Linux,系统缺失字体
    Android 联系人字母排序(仿微信)
    Android之ORMLite实现数据持久化的简单使用
    设计模式之多例模式
    设计模式之单例模式
  • 原文地址:https://www.cnblogs.com/afish/p/4204218.html
Copyright © 2011-2022 走看看