phpcmsV9 全站搜索功能如何实现

5 篇文章 0 订阅

给大家分享一下如何运用搜索功能吧,

1. 首先, 模块->全站搜索->添加搜索分类,添加搜索分类,此时生成的ID为typeid

 

2. 添加form表单,此时的typeid即为上图的id,siteid为站点的id

<form method="get" action="{APP_PATH}index.php" target="_blank">
   <td width="">搜索:</td>
   <td width="">
     <input type="text" name="q" id="q" value="" class="inputCom" style="width:196px; height:22px; line-height:22px;">
     <input type="hidden" name="m" value="search"/>
     <input type="hidden" name="c" value="index"/>
     <input type="hidden" name="a" value="init"/>
     <input type="hidden" name="typeid" value="{$typeid}" id="typeid"/>
     <input type="hidden" name="siteid" value="{$siteid}" id="siteid"/>
   </td>
   <td width=""><input type="image" src="{IMG_PATH}sousuo.jpg" border="0" class="sousuo" id="search_btn"></td>
</form>

3.修改搜索页面   phpcms\templates\default\search\list.html

{pc:get sql="SELECT * FROM `表名` where title like '%$q%' order by id DESC " num="10" page="$page" return="data"}
    {loop $data $r}
    <tr>
       <td width="500" align="left" style="margin-top:2px; ">· <a href="{$r[url]}" title="{$r[title]}" class="centerTitle" style="text-decoration:none" >{$r[title]}</a></td>
       <td width="200" align="right" style="color:#FF6600;margin-top:2px;">{date('Y-m-d',$r[inputtime])}</td>
    </tr>
    {/loop}
    {if empty($data)}未找到结果{/if}
    <div class="pages">{$pages}</div>
{/pc}

此时,搜索页面就可以了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值