DedeCMS搜索是固定的模板,搜索結(jié)果也是全站范圍。搜索頁面不參與SEO排名,應(yīng)用nofollow禁止蜘蛛抓取,title最好也不要寫搜索詞。下面介紹網(wǎng)站建設(shè)中根據(jù)不同的內(nèi)容模型顯示不同的模板。
建立常見問題內(nèi)容模型及欄目
常見問題FAQ應(yīng)區(qū)別于其他模型,不然在搜索的時(shí)候出現(xiàn)問題,新建FAQ內(nèi)容模型ID為7(根據(jù)實(shí)際情況修改);
在模板文件夾里,常見問題FAQ用search_faq.htm模板,普通搜索用search.htm模板。
模板增加識別內(nèi)容模型ID的JS代碼
在需要的模板(比如index.htm)</head>之前加入
<script language="javascript" type="text/javascript">function Check(){ if(document.formsearch.channeltype.value=="1"){ document.formsearch.action="{dede:field name='phpurl'/}/search.php"; }else{ document.formsearch.action="{dede:field name='phpurl'/}/search_faq.php"; } } </script>
搜索表單代碼
<form name="formsearch" action="" onsubmit="Check();"><p class="form"> <input type="hidden" name="kwtype" value="0" /> <input name="q" type="text" class="search-keyword" id="search-keyword" value="{dede:global name='keyword' function='RemoveXSS(@me)'/}" /> <select name="channeltype" id="channeltype" > <option value='1'selected='1'>文章</option><!--文章模型id=1--> <option value='7'>FAQ</option><!--新增內(nèi)容模型id=7--> </select> <button type="submit" class="search-submit">搜索</button> </p> </form>
新增搜索/plus/search_faq.php,/include/arc.searchview_faq.class.php
找到/plus/search.php,復(fù)制一份并更名為search_faq.php。
打開search_faq.php,找到
require_once(DEDEINC."/arc.searchview.class.php");
更改為
require_once(DEDEINC."/arc.searchview_faq.class.php");
找到/include/arc.searchview.class.php,復(fù)制一份并更名為arc.searchview_faq.class.php。
打開arc.searchview_faq.class.php,找到
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search.htm";
修改為
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search_faq.htm";