织梦后台回收站添加id和关键词搜索
效果图如下:
支持id搜索,关键词搜索,同时支持id和关键词关联搜索。
方法如下:
一,模板htm代码:
找到后台所在的文件夹(dede),打开对应的templets文件夹,找到“recycling.htm”文件,打开编辑,添加如下代码(ps:这段代码完全可以在织梦后台“所有栏目列表中找到,你懂的”):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <form name="form3" action="recycling1.php" method="get"> <input type="hidden" name="dopost" value="listArchives"> <table width="98%" border="0" cellpadding="1" cellspacing="1" bgcolor="#cfcfcf" align="center" style="margin-top:8px"> <tbody><tr bgcolor="#EEF4EA"> <td background="images/wbg.gif" align="center"> <table border="0" cellpadding="0" cellspacing="0" height="32"> <tbody> <tr> <td>id:</td> <td><input type="text" name="id" value="" style="width:80px"></td> <td style="width: 20px"></td> <td style="margin-left: 10px;"> 关键字: </td> <td width="130"> <input type="text" name="keyword" value="" style="width:120px"> </td> <td> <input name="imageField" type="image" src="images/button_search.gif" width="60" height="22" border="0" class="np"> </td> </tr> </tbody></table> </td> </tr> </tbody></table> </form> |
二、程序php代码:
把以下代码创建一个文件名为:recycling1.php 的文件,将其上传到后台根目录下(dede或者你修改过的),代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?php require_once(dirname(__FILE__).'/config.php'); CheckPurview('a_List,a_AccList,a_MyList'); require_once(DEDEINC.'/datalistcp.class.php'); $id = $_GET['id']; if($id==''){ $idzhi = "1=1"; }else{ $idzhi = "id=$id"; } $keyword = $_GET['keyword']; if($keyword==''){ $query = 'select * from `#@__archives` where arcrank ="-2" and '.$idzhi.' order by id desc'; }else{ $query = "select * from `#@__archives` where title LIKE '%".$keyword."%' and ".$idzhi." and arcrank = '-2' order by id desc"; } $dlist = new DataListCP(); $dlist->SetTemplet(DEDEADMIN."/templets/recycling.htm"); $dlist->SetSource($query); $dlist->display(); |
完成以上代码,你的织梦网站后台内容回收站就有了搜索的功能了。
感觉不错记得打赏支持小灰灰哦~~~