织梦搜索实现标题完全精准搜索,就是搜索文档标题必须一模一样才有搜索结果
- 实现教程
在 /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>