利用织梦高级搜索功能 , 来定制线上授权信息查询系统
织梦默认的高级搜索,就是这个页面/plus/advancedsearch.PHP,他是模糊搜索.而且会出现多条结果,需要修改为单条信息搜索.
后台,核心,模型管理,在原模型或新建立的模型中,增加字段.比如增加身份证字段.
然后返回模型管理,找到模型后面的放大镜图标,点击一下.如下图.
下面模板选择,默认是利用官方默认模板中的advancedsearch.htm 模板
点击确定后,就会自动出现搜索代码.
还需要修改plus/advancedsearch.php 这个文件.
大约在142行. 如下为修改后的效果.就是把模糊查询为精准查询.并增加一个不为空的判断.
1
2
3
4
5
6
7
8
9
10 <span class="hljs-keyword">if</span>(isset(<span class="hljs-variable">${</span><span class="hljs-variable">$var</span>}) && trim(<span class="hljs-variable">${</span><span class="hljs-variable">$var</span>})!=<span class="hljs-string">''</span>)
{
<span class="hljs-variable">${</span><span class="hljs-variable">$var</span>} = stripslashes(<span class="hljs-variable">${</span><span class="hljs-variable">$var</span>});
<span class="hljs-variable">${</span><span class="hljs-variable">$var</span>} = preg_replace(<span class="hljs-string">"#[\|"\r\n\t%\*\?\(\)\$;,'%<>]#"</span>, <span class="hljs-string">""</span>, trim(<span class="hljs-variable">${</span><span class="hljs-variable">$var</span>}));
<span class="hljs-variable">${</span><span class="hljs-variable">$var</span>} = addslashes(<span class="hljs-variable">${</span><span class="hljs-variable">$var</span>});
<span class="hljs-regexp">//</span><span class="hljs-variable">$where</span> .= <span class="hljs-string">" AND addon.$var LIKE '%${$var}%'"</span>;
<span class="hljs-variable">$where</span> .= <span class="hljs-string">" AND addon.$var = '${$var}'"</span>;
}
<span class="hljs-keyword">else</span>{
<span class="hljs-constant">ShowMsg</span>(<span class="hljs-string">'身份证不能为空,或输入不正确'</span>,-<span class="hljs-number">1</span>,<span class="hljs-number">0</span>);exit;}
向下.
在下面这几行的下面增加.
1
2
3
4
5 <span class="hljs-keyword">else</span>
{
<span class="hljs-variable">$sql</span> = urldecode(<span class="hljs-variable">$sql</span>);
<span class="hljs-variable">$query</span> = <span class="hljs-variable">$sql</span>;
}
增加如下代码,下面是修改后的效果
1
2
3
4
5
6
7
8
9
10
11
12 <span class="hljs-keyword">else</span>
{
<span class="hljs-variable">$sql</span> = urldecode(<span class="hljs-variable">$sql</span>);
<span class="hljs-variable">$query</span> = <span class="hljs-variable">$sql</span>;
}
//<span class="hljs-built_in">print</span>_r(<span class="hljs-variable">$sql</span>);<span class="hljs-built_in">exit</span>;
<span class="hljs-variable">$searchinfo2</span> = <span class="hljs-variable">$dsql</span>->GetOne(<span class="hljs-variable">$sql</span>);
<span class="hljs-keyword">if</span>(!is_array(<span class="hljs-variable">$searchinfo2</span>))
{
showmsg(<span class="hljs-string">'查询的授权信息不存在,请检查输入'</span>,<span class="hljs-string">'-1'</span>);
<span class="hljs-built_in">exit</span>();
}
如果模板上不显示自定义字段,可以参考这篇文章:dede自定义搜索结果页显示自定义字段
原创文章,转载请注明: 转载自广州SEO
本文链接地址: 利用织梦高级搜索功能 , 来定制线上授权信息查询系统