官方微博: 腾讯  
首页 > ECSHOP教程 > ECSHOP二次开发 > ECSHOP二次开发教程 > ecshop首页文章搜索框功能增加方法

ecshop首页文章搜索框功能增加方法

ECSHOP教程 / ecshop 教程网(www.ecshop119.com) 2015-01-14

ecshop首页增加文章搜索框功能方法:

怎么样让ecshop商城首页有商品搜索框,同时又可以搜索文章?

 

1.首页lbi库文件需要显示地方:

 

增加:

 

             <form action="{$search_url}" name="search_form" method="post" class="article_search">
        <input name="keywords" type="text" id="requirement" value="{$search_value}" class="inputBg" />
        <input name="id" type="hidden" value="{$cat_id}" />
        <input name="cur_url" id="cur_url" type="hidden" value="" />
        <input type="submit" value="{$lang.button_search}" class="bnt_blue_1" />
      </form>

 

 

2.在inculudes/lib_article.php 中
找出下列语句,并修改。【约42行】
//增加搜索条件,如果有搜索内容就进行搜索 
if ($requirement != '')
{
$sql = 'SELECT article_id, title, author, add_time, file_url, open_type' .
' FROM ' .$GLOBALS['ecs']->table('article') .
' WHERE is_open = 1 AND ' . $cat_str . ' AND  title like \'%' . $requirement . '%\'  .//本行为要修改语句 Edited by Lingfeng
' ORDER BY article_type DESC, article_id DESC';
}
所修改句子为:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
' WHERE is_open = 1 AND ' . $cat_str . ' AND  (title like \'%' . $requirement . '%\' or content like \'%' . $requirement . '%\' )' .
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
2.再找出:
function get_article_count($cat_id ,$requirement='')
{
global $db, $ecs;
if ($requirement != '')
{
$count = $db->getOne('SELECT COUNT(*) FROM ' . $ecs->table('article') . ' WHERE ' . get_article_children($cat_id) . ' AND  title like \'%' . $requirement . '%\'  and is_open = 1');
}
所修改后句子为:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
$count = $db->getOne('SELECT COUNT(*) FROM ' . $ecs->table('article') . ' WHERE ' . get_article_children($cat_id) . ' AND ( title like \'%' . $requirement . '%\' or content like \'%' . $requirement . '%\')  AND is_open = 1');
-------------------------------------------------------------------

这样以后首页就可以搜索文章了哦

转载请注明:ECshop119模板屋-ECshop教程网(全国最专业的ECSHOP插件制作商-专业ECSHOP二次开发)

帮助目录

在线反馈

可以将问题或建议反馈给我们。

提交在线反馈

与网友交流ECSHOP开发修改。

加入QQ群交流