曾彩飞 發表於 2023-8-21 00:00:00

让Dedecms自带搜索实现全文检索(支持标题与内容)

<p>
        <span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>登陆Dedecms 后台—核心—频道模型—内容模型管理—普通文章—点击后面那个放大镜标志(最重要一步)—附件表可供自定义搜索的字段,这里的字段是程序依据字段类型自动 选择生成的,将“文章内容”前面那个打勾,此时将修改掉搜索字段,但是还没有成功,还需要修改模板相应的代码。 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>将模板文件head.htm 中的以下代码: </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        &lt;form action="{dede:field name='phpurl'/}/search.php" name="formsearch"&gt; <br>
        &lt;div class="form"&gt; <br>
        &lt;h4&gt;搜索&lt;/h4&gt; <br>
        &lt;input type="hidden" name="kwtype" value="0" /&gt; <br>
        &lt;input name="keyword" type="text" class="search-keyword" id="search-keyword" /&gt; <br>
        &lt;select name="searchtype" class="search-option" id="search-option"&gt; <br>
        &lt;option value="titlekeyword" selected='1'&gt;智能模糊搜索&lt;/option&gt; <br>
        &lt;option value="title"&gt;仅搜索标题&lt;/option&gt; <br>
        &lt;/select&gt; <br>
        &lt;button type="submit" class="search-submit"&gt;搜索&lt;/button&gt; <br>
        &lt;/div&gt; <br>
        &lt;/form&gt; </p>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>修改为: </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        &lt;form action="/plus/advancedsearch.php" method="post"&gt; <br>
        &lt;div class="form"&gt; <br>
        &lt;h4&gt;搜索&lt;/h4&gt; <br>
        &lt;input type="hidden" name="mid" value="1" /&gt; <br>
        &lt;input type="hidden" name="dopost" value="search" /&gt; <br>
        关键词:&lt;input type="text" name="q" /&gt; &lt;input type="submit" name="submit" value="开始全文搜索" /&gt;&lt;/div&gt; <br>
        &lt;/form&gt; </p>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>此时更新网站,将会发现搜索数据已经有了质的飞跃! </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>但同时带来的问题是,会降低效率。如果访问量过大不建议这样操作。</span></p>
頁: [1]
查看完整版本: 让Dedecms自带搜索实现全文检索(支持标题与内容)