• 【转】ZenCart:增加Popular Search


    原文地址:http://www.fuyahui.com/zencart-add-popular-search.html

    --------------------------------------------------------------------------

    第一步执行数据库,代码如下

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8 */;
    CREATE TABLE IF NOT EXISTS `customers_searches` (`search` varchar(255) NOT NULL DEFAULT '',
    `language_id` int(11) unsigned DEFAULT NULL,`freq` tinyint(3) unsigned DEFAULT '0',PRIMARY KEY (`search`) USING BTREE,
    KEY `lang` (`language_id`))ENGINE=MyISAM DEFAULT CHARSET=utf8;

    第二步修改文件includes\modules\pages\advanced_search_result\header_php.php,也可以修改includes\application_bottom.php增加如下代码

    /* 数据库中表customers_searches增加搜索次数和关键词*/
    if ($_GET['keyword'] != '') {
    $search_count = $db->Execute("select freq from customers_searches where search = '". $_GET['keyword'] . "'");
    if (!$search_count->RecordCount()) {
    $db->Execute("insert into customers_searches (search,language_id, freq) values
    ('". $_GET['keyword'] ."','". $_SESSION['languages_id'] ."',1)");
    } else {
    $db->Execute("update customers_searches set freq =
    " . ($search_count->fields['freq']+1) . " where search = '". $_GET['keyword'] . "'");
    }

    第三步增加一个文件includes\modules\sideboxes\你自己的模板名称\popular_searches.php  代码如下  可以根据自己的需求进行修改。

    <div id="information" style=" 170px">
    <div>
    <h3 id="informationHeading"><?php echo TEXT_BOX_POPULAR_SEARCHES;?></h3>
    </div>
    <div id="informationContent">
    <ul style="margin: 0; padding: 0; list-style-type: none;">
    <?php$popularSearches = $db->Execute('select search,freq from customers_searches limit 12');
    $popularContent_i = 0;while(!$popularSearches->EOF){$popularContent ='';
    $popularContent .= '<a href="'.zen_href_link(FILENAME_ADVANCED_SEARCH_RESULT,
    'keyword='.$popularSearches->fields['search'], 'NONSSL').'" _fcksavedurl="'.
    zen_href_link(FILENAME_ADVANCED_SEARCH_RESULT,'keyword='.$popularSearches->fields['search'], 'NONSSL').'">';
    if($popularSearches->fields['freq'] >10){$popularContent .= '<strong style="color:red;">';
    }$popularContent .= $popularSearches->fields['search'];
    if($popularSearches->fields['freq']>10){$popularContent .= '</strong>';}$popularContent .= '</a>';
    if($popularContent_i < $popularSearches->RecordCount()){$popularContent .= ', ';
    $popularContent_i++;}echo $popularContent;$popularSearches->MoveNext();}?>
    </ul>
    </div>
    </div>

    第四步在includes\languages\english.php中添加如下文字

    define('TEXT_BOX_POPULAR_SEARCHES','Popular Searches');
  • 相关阅读:
    7--docker-compose详解
    6--容器数据卷,发布镜像,Docker小结
    5-- Dockerfile 搭建 博客系统
    4--Docker之Dockerfile镜像定制
    3--Docker网络 ; Docker图形化界面
    2--Docker容器相关命令
    1--docker介绍、安装; docker镜像相关命令
    2、函数的核心内容
    1、函数的基本使用
    7、文件操作方法
  • 原文地址:https://www.cnblogs.com/xiangniu/p/2518366.html
Copyright © 2020-2023  润新知