沁水凌兰 發表於 2023-7-18 00:00:00

dedecms织梦给后台管理员列表增加搜索功能的示例代码

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        最近用织梦系统给一个客户做了一个管理系统,客户分配的管理员账户达到了300多个,搜索起来很不方便,应客户要求要加一个管理员账户搜索功能,其实做起来蛮容易的,修改文件涉及两个,首先打开文件:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        1、默认为/dede/templets/sys_admin_user.htm,在合适的位置加入代码:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:xhtml;">
&lt;form action="sys_admin_user.php" name="form1" method="get"&gt;
      &lt;table border="0" cellspacing="0" cellpadding="3"&gt;
      &lt;tr&gt;
          &lt;td&gt;管理员搜索:&lt;/td&gt;
          &lt;td&gt;&lt;input name="keyword" type="text" id="keyword" size="12" value="{dede:global name='keyword'/}" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input name="imageField" class="np" type="image" src="images/button_search.gif" width="60" height="22" border="0" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        2、找到/dede/sys_admin_user.php,找到:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
else $rank = " WHERE CONCAT(dede_admin.usertype)='$rank' ";
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        在这个的下面加入:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
if(!isset($keyword)) $keyword = '';
else $keyword = trim(FilterSearch($keyword));

找到:$query = "SELECT dede_admin.*,dede_arctype.typename FROM dede_admin LEFT JOIN dede_arctype ON dede_admin.typeid = dede_arctype.id $rank ";,修改为:
if($keyword&lt;&gt;'')
{
$query = "SELECT dede_admin.*,dede_arctype.typename FROM dede_admin LEFT JOIN dede_arctype ON dede_admin.typeid = dede_arctype.id $rankwhere userid LIKE '%$keyword%' OR uname LIKE '%$keyword%'";
}
else
{
$query = "SELECT dede_admin.*,dede_arctype.typename FROM dede_admin LEFT JOIN dede_arctype ON dede_admin.typeid = dede_arctype.id $rank ";
}
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        到这里就完成了,做好了去试下,是不是很好用。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁: [1]
查看完整版本: dedecms织梦给后台管理员列表增加搜索功能的示例代码