搜索页面进行全站检索,不涉及太多高级检索功能,有这方面需求的搜索,需要二次开发。
一般企业网站在首页有热门搜索关键字,可在系统后台基本参数进行设置。然后前台调用代码如下:
<?php $arr=explode(',',$config['hotsearch']); foreach($arr as $k=>$v){ echo "<a style='font-size: 14px; color: #666; padding-left: 10px;' href='index/searchs.html?keywords=$v'>$v</a>"; } ?>
热门搜索:<?php $arr=explode(',',$config['hotsearch']); foreach($arr as $k=>$v){ echo "<a style='font-size: 14px; color: #666; padding-left: 10px;' href='index/searchs.html?keywords=$v'>$v</a>"; } ?>
代码解释: 核心的地方一处: 提交的地址为:index/search/index
search.htm 为搜索页模板,{$keywords} 关键字标签,默认情况下,搜索关键字标记为红色,且每页显示5条,自动分页。
以下是关于"{$keywords}"的搜索结果{volist name="$searchres" id="art" empty="暂无数据"}
- {/volist}
{:htmlspecialchars_decode(subtext($art['title'],60))}
时间:{$art.time|date="Y-m-d"}浏览量:{$art.click}{$art.description | subtext=70}
{if condition="$art.litpic neq ''"} {else /} {/if}{:htmlspecialchars_decode($page)}
搜索分页: {:htmlspecialchars_decode($page)}