織夢搜索實現標題完全精準搜索,就是搜索文檔標題必須一模一樣才有搜索結果
- 實現教程
在 /plus/新建一個so.php文件
<?phprequire_once(dirname(__FILE__) . "/../include/common.inc.php");require_once DEDEINC . "/arc.partview.class.php";if ($title == ''){ShowMsg('關鍵字不能為空!', '-1');exit();}$row = $dsql->GetOne("SELECT id FROM `dede_archives` WHERE title = '$title' ");if (is_array($row)){$chRow = $dsql->GetOne("SELECT c.addtable FROM dede_archives AS a LEFT JOIN dede_channeltype AS c ON a.channel=c.id where a.id='{$row['id']}'");$addtable = trim($chRow['addtable']);$result = $dsql->GetOne("SELECT arc.*,addf.* FROM `dede_archives` arc LEFT JOIN `{$addtable}` addf ON arc.id=addf.aid WHERE arc.arcrank>-1 AND arc.id = '{$row['id']}'");$pv = new PartView();foreach ($result as $k => $v){$pv->Fields[$k] = $v;}$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $cfg_df_style . "/so.htm");$pv->Display();}else{ShowMsg('沒有相關記錄!', '-1');}exit();
你的模板文件夾里添加1個so.htm模板文件
<div><p>標題:{dede:field.title /}</p><p>縮略圖:{dede:field.litpic /}</p><p>品牌:{dede:field.pinpai /}</p><p>貨號:{dede:field.huohao /}</p><p>價格:{dede:field.jiage /}</p><p>內容:{dede:field.body /}</p></div>
前端模板搜索框代碼
<form method="post" action="{dede:global.cfg_cmspath/}/plus/so.php" ><div id="search_box"><p>標題精準搜索:<input type="text" name="title" value="" /></p><input type="submit" name="submit" value="開始搜索" /></div></form>


