首頁  >  文章  >  CMS教程  >  phpcms v9搜尋功能怎麼做

phpcms v9搜尋功能怎麼做

藏色散人
藏色散人原創
2020-02-03 10:57:333640瀏覽

phpcms v9搜尋功能怎麼做

phpcms v9搜尋功能怎麼做? phpcmsV9 全站搜尋功能如何實現

給大家分享一下如何運用搜尋功能吧,

1. 首先, 模組->全站搜尋- >新增搜尋分類,新增搜尋分類,此時產生的ID為typeid

phpcms v9搜尋功能怎麼做

 

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 &#39;%$q%&#39; 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(&#39;Y-m-d&#39;,$r[inputtime])}</td>
    </tr>
    {/loop}
    {if empty($data)}未找到结果{/if}
    <div class="pages">{$pages}</div>
{/pc}

此時,搜尋頁面就可以了。

PHP中文網,大量的免費PHPCMS教學,歡迎線上學習!

以上是phpcms v9搜尋功能怎麼做的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn