ecshop二次开发--热词搜索且显示
2016-10-21 16:26
399 查看
1.进入upload->themes->degault->library->page_header.lbi中搜索以下代码
[python]
view plain
copy
{if $searchkeywords}
{$lang.hot_search} :
{foreach from=$searchkeywords item=val}
<a href="search.php?keywords={$val|esc
4000
ape:url}">{$val}</a>
{/foreach}
{/if}
2把搜索到的代码替换为一下代码
[python]
view plain
copy
{$lang.hot_search} :
{if $searchkeywords}
{foreach from=$searchkeywords item=val}
<a href="search.php?keywords={$val|escape:url}">{$val}</a>
{/foreach}
{/if}
// 数据库ecs_keywords 表中的数据
{if $searchengine}
{foreach from=$searchengine item=val}
{foreach from=$val key=key item=v}
<a href="search.php?keywords={$key|escape:url}">{$key}</a>
{/foreach}
{/foreach}
{/if}
3.进入upload->admin->searchengie_stats.PHP复制一下代码
[python]
view plain
copy
/* 时间参数 */
/* TODO: 时间需要改 */
if (isset($_POST) && !empty($_POST))
{
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
}
else
{
$start_date = local_date('Y-m-d', strtotime('-1 week'));
$end_date = local_date('Y-m-d');
}
/* ------------------------------------- */
/* --综合流量
/* ------------------------------------- */
$max = 0;
$general_xml = "<chart caption='$_LANG[tab_keywords]' shownames='1' showvalues='0' decimals='0' numberPrefix='' outCnvBaseFontSize='12' baseFontSize='12'>";
$sql = "SELECT keyword, count, searchengine ".
" FROM " .$ecs->table('keywords').
" WHERE date >= '$start_date' AND date <= '" .$end_date. "'";
if (isset($_POST['filter']))
{
$sql .= ' AND '. db_create_in($_POST['filter'], 'searchengine');
}
$res = $db->query($sql);
$search = array();
$searchengine = array();
$keyword = array();
while ($val = $db->fetchRow($res))
{
$keyword[$val['keyword']] = 1;
$searchengine[$val['searchengine']][$val['keyword']] = $val['count'];
}
4.将你复制到的代码放入到upload->includes->lib_main.php后找到assign_template方法后,将你复制到的代码放到assign_template后
注意:第四步是我已经将第三部代码所整合在一起了,所以在这里第三部你可以省下不用写。
以下代码是我将我所复制的代码放到assign_template方法后的效果
[python]
view plain
copy
function assign_template($ctype = '', $catlist = array())
{
global $smarty;
$smarty->assign('image_width', $GLOBALS['_CFG']['image_width']);
$smarty->assign('image_height', $GLOBALS['_CFG']['image_height']);
$smarty->assign('points_name', $GLOBALS['_CFG']['integral_name']);
$smarty->assign('qq', explode(',', $GLOBALS['_CFG']['qq']));
$smarty->assign('ww', explode(',', $GLOBALS['_CFG']['ww']));
$smarty->assign('ym', explode(',', $GLOBALS['_CFG']['ym']));
$smarty->assign('msn', explode(',', $GLOBALS['_CFG']['msn']));
$smarty->assign('skype', explode(',', $GLOBALS['_CFG']['skype']));
$smarty->assign('stats_code', $GLOBALS['_CFG']['stats_code']);
$smarty->assign('copyright', sprintf($GLOBALS['_LANG']['copyright'], date('Y'), $GLOBALS['_CFG']['shop_name']));
$smarty->assign('shop_name', $GLOBALS['_CFG']['shop_name']);
$smarty->assign('service_email', $GLOBALS['_CFG']['service_email']);
$smarty->assign('service_phone', $GLOBALS['_CFG']['service_phone']);
$smarty->assign('shop_address', $GLOBALS['_CFG']['shop_address']);
$smarty->assign('licensed', license_info());
$smarty->assign('ecs_version', VERSION);
$smarty->assign('icp_number', $GLOBALS['_CFG']['icp_number']);
$smarty->assign('username', !empty($_SESSION['user_name']) ? $_SESSION['user_name'] : '');
$smarty->assign('category_list', cat_list(0, 0, true, 2, false));
$smarty->assign('catalog_list', cat_list(0, 0, false, 1, false));
$smarty->assign('navigator_list', get_navigator($ctype, $catlist)); //自定义导航栏
if (!empty($GLOBALS['_CFG']['search_keywords']))
{
$searchkeywords = explode(',', trim($GLOBALS['_CFG']['search_keywords']));
}
else
{
$searchkeywords = array();
}
$smarty->assign('searchkeywords', $searchkeywords);
/* 时间参数 */
/* TODO: 时间需要改 */
if (isset($_POST) && !empty($_POST))
{
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
}
else
{
$start_date = local_date('Y-m-d', strtotime('-1 week'));
$end_date = local_date('Y-m-d');
}
/* ------------------------------------- */
/* --综合流量
/* ------------------------------------- */
$max = 0;
//$general_xml = "<chart caption='$_LANG[tab_keywords]' shownames='1' showvalues='0' decimals='0' numberPrefix='' outCnvBaseFontSize='12' baseFontSize='12'>";
$sql = "SELECT keyword, count, searchengine "
ad9e
.
" FROM " .$GLOBALS['ecs']->table('keywords').
" WHERE date >= '$start_date' AND date <= '" .$end_date. "'order by count desc limit 5";
if (isset($_POST['filter']))
{
$sql .= ' AND '. db_create_in($_POST['filter'], 'searchengine');
}
$res = $GLOBALS['db']->query($sql);
$search = array();
$searchengine = array();
$keyword = array();
while ($val = $GLOBALS['db']->fetchRow($res))
{
$keyword[$val['keyword']] = 1;
$searchengine[$val['searchengine']][$val['keyword']] = $val['count'];
}
$smarty->assign("searchengine",$searchengine);
}
5.这样所做的搜索就到此完毕了。
第一种案例演示:
第二种案例演示:(直接从后台进行添加,你所想要搜索的词语)
[python]
view plain
copy
{if $searchkeywords}
{$lang.hot_search} :
{foreach from=$searchkeywords item=val}
<a href="search.php?keywords={$val|esc
4000
ape:url}">{$val}</a>
{/foreach}
{/if}
2把搜索到的代码替换为一下代码
[python]
view plain
copy
{$lang.hot_search} :
{if $searchkeywords}
{foreach from=$searchkeywords item=val}
<a href="search.php?keywords={$val|escape:url}">{$val}</a>
{/foreach}
{/if}
// 数据库ecs_keywords 表中的数据
{if $searchengine}
{foreach from=$searchengine item=val}
{foreach from=$val key=key item=v}
<a href="search.php?keywords={$key|escape:url}">{$key}</a>
{/foreach}
{/foreach}
{/if}
3.进入upload->admin->searchengie_stats.PHP复制一下代码
[python]
view plain
copy
/* 时间参数 */
/* TODO: 时间需要改 */
if (isset($_POST) && !empty($_POST))
{
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
}
else
{
$start_date = local_date('Y-m-d', strtotime('-1 week'));
$end_date = local_date('Y-m-d');
}
/* ------------------------------------- */
/* --综合流量
/* ------------------------------------- */
$max = 0;
$general_xml = "<chart caption='$_LANG[tab_keywords]' shownames='1' showvalues='0' decimals='0' numberPrefix='' outCnvBaseFontSize='12' baseFontSize='12'>";
$sql = "SELECT keyword, count, searchengine ".
" FROM " .$ecs->table('keywords').
" WHERE date >= '$start_date' AND date <= '" .$end_date. "'";
if (isset($_POST['filter']))
{
$sql .= ' AND '. db_create_in($_POST['filter'], 'searchengine');
}
$res = $db->query($sql);
$search = array();
$searchengine = array();
$keyword = array();
while ($val = $db->fetchRow($res))
{
$keyword[$val['keyword']] = 1;
$searchengine[$val['searchengine']][$val['keyword']] = $val['count'];
}
4.将你复制到的代码放入到upload->includes->lib_main.php后找到assign_template方法后,将你复制到的代码放到assign_template后
注意:第四步是我已经将第三部代码所整合在一起了,所以在这里第三部你可以省下不用写。
以下代码是我将我所复制的代码放到assign_template方法后的效果
[python]
view plain
copy
function assign_template($ctype = '', $catlist = array())
{
global $smarty;
$smarty->assign('image_width', $GLOBALS['_CFG']['image_width']);
$smarty->assign('image_height', $GLOBALS['_CFG']['image_height']);
$smarty->assign('points_name', $GLOBALS['_CFG']['integral_name']);
$smarty->assign('qq', explode(',', $GLOBALS['_CFG']['qq']));
$smarty->assign('ww', explode(',', $GLOBALS['_CFG']['ww']));
$smarty->assign('ym', explode(',', $GLOBALS['_CFG']['ym']));
$smarty->assign('msn', explode(',', $GLOBALS['_CFG']['msn']));
$smarty->assign('skype', explode(',', $GLOBALS['_CFG']['skype']));
$smarty->assign('stats_code', $GLOBALS['_CFG']['stats_code']);
$smarty->assign('copyright', sprintf($GLOBALS['_LANG']['copyright'], date('Y'), $GLOBALS['_CFG']['shop_name']));
$smarty->assign('shop_name', $GLOBALS['_CFG']['shop_name']);
$smarty->assign('service_email', $GLOBALS['_CFG']['service_email']);
$smarty->assign('service_phone', $GLOBALS['_CFG']['service_phone']);
$smarty->assign('shop_address', $GLOBALS['_CFG']['shop_address']);
$smarty->assign('licensed', license_info());
$smarty->assign('ecs_version', VERSION);
$smarty->assign('icp_number', $GLOBALS['_CFG']['icp_number']);
$smarty->assign('username', !empty($_SESSION['user_name']) ? $_SESSION['user_name'] : '');
$smarty->assign('category_list', cat_list(0, 0, true, 2, false));
$smarty->assign('catalog_list', cat_list(0, 0, false, 1, false));
$smarty->assign('navigator_list', get_navigator($ctype, $catlist)); //自定义导航栏
if (!empty($GLOBALS['_CFG']['search_keywords']))
{
$searchkeywords = explode(',', trim($GLOBALS['_CFG']['search_keywords']));
}
else
{
$searchkeywords = array();
}
$smarty->assign('searchkeywords', $searchkeywords);
/* 时间参数 */
/* TODO: 时间需要改 */
if (isset($_POST) && !empty($_POST))
{
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
}
else
{
$start_date = local_date('Y-m-d', strtotime('-1 week'));
$end_date = local_date('Y-m-d');
}
/* ------------------------------------- */
/* --综合流量
/* ------------------------------------- */
$max = 0;
//$general_xml = "<chart caption='$_LANG[tab_keywords]' shownames='1' showvalues='0' decimals='0' numberPrefix='' outCnvBaseFontSize='12' baseFontSize='12'>";
$sql = "SELECT keyword, count, searchengine "
ad9e
.
" FROM " .$GLOBALS['ecs']->table('keywords').
" WHERE date >= '$start_date' AND date <= '" .$end_date. "'order by count desc limit 5";
if (isset($_POST['filter']))
{
$sql .= ' AND '. db_create_in($_POST['filter'], 'searchengine');
}
$res = $GLOBALS['db']->query($sql);
$search = array();
$searchengine = array();
$keyword = array();
while ($val = $GLOBALS['db']->fetchRow($res))
{
$keyword[$val['keyword']] = 1;
$searchengine[$val['searchengine']][$val['keyword']] = $val['count'];
}
$smarty->assign("searchengine",$searchengine);
}
5.这样所做的搜索就到此完毕了。
第一种案例演示:
第二种案例演示:(直接从后台进行添加,你所想要搜索的词语)
相关文章推荐
- ecshop二次开发--热词搜索且显示
- 二次开发 ECShop首页热门搜索关键词实现随机显示
- ecshop二次开发--热词搜索且显示
- ECSHOP二次开发,在用户中心的订单详情页显示商品缩略图
- ecshop二次开发--添加普通时间显示
- FlexPaper二次开发问题及搜索高亮显示
- ECSHOP二次开发,在用户中心的订单详情页显示商品缩略图
- ECSHOP二次开发,在用户中心的订单详情页显示商品缩略图
- ecshop二次开发--添加普通时间显示
- ecshop二次开发:添加最新交易滚动显示功能
- ecshop二次开发——商品列表页显示重量、货号、购买数量
- [OK]ecshop二次开发:商品分类添加图片显示功能
- 【笔记】ecshop二次开发视频教程基础篇(第七讲)商品列表显示
- ecshop二次开发:商品分类添加图片显示功能(附下载)
- ecshop二次开发之 修改ecshop购物车退出后保留购物车购买的商品
- ecshop二次开发:ecshop库表结构完整版(一)
- UG二次开发:内部模式时如何调用控制台显示?
- ecshop二次开发指南[转]
- PHP:SMS移动短信接口二次开发中的插入多行记录操作(含实时进度显示)
- 去除ecshop二次开发后底部出现跑来跑去的版权信息