帝國cms7.5批量推送信息到分類標題插件
帝國cms實現批量推送信息到標題分類,原理和推薦到專題一樣,可以通過后臺多選然后推送,這樣可以提高后臺編輯效率,不用一條條修改。
第一步,在e/admin/文件夾下新建一個文件夾pushinfotype,再新建一個php文件,命名為PushToInfoType.php。將下列代碼粘貼到PushToInfoType.php。
第一步,在e/admin/文件夾下新建一個文件夾pushinfotype,再新建一個php文件,命名為PushToInfoType.php。將下列代碼粘貼到PushToInfoType.php。
如圖:
- <?php
- ini_set("display_errors", "On");
- error_reporting(E_ALL | E_STRICT);
- define('EmpireCMSAdmin','1');
- require("../../class/connect.php");
- require("../../class/db_sql.php");
- require("../../class/functions.php");
- require "../".LoadLang("pub/fun.php");
- require("../../class/t_functions.php");
- require("../../data/dbcache/class.php");
- require("../../data/dbcache/MemberLevel.php");
- require("../../class/chtmlfun.php");
- $link=db_connect();
- $empire=new mysqlquery();
- $editor=1;
- //驗證用戶
- $lur=is_login();
- $logininid=$lur['userid'];
- $loginin=$lur['username'];
- $loginrnd=$lur['rnd'];
- $loginlevel=$lur['groupid'];
- $loginadminstyleid=$lur['adminstyleid'];
- //ehash
- $ecms_hashur=hReturnEcmsHashStrAll();
- //推送信息到標題分類
- function PushInfoToType($add,$userid,$username){
- global $empire,$dbtbpre,$lur,$class_r;
- $classid=(int)$add['classid'];
- $cid=(int)$add['cid'];
- $id=explode(',',$add[ids]);
- $count=count($id);
- //表名
- $tbname='';
- if($classid)
- {
- $tbname=$class_r[$classid]['tbname'];
- }
- if(!$tbname)
- {
- printerror('ErrorUrl','');
- }
- for($i=0;$i<$count;$i++)
- {
- $myid=intval($id[$i]);
- $empire->query("update {$dbtbpre}ecms_".$tbname." SET ttid='$cid' where classid='$classid' and id='$myid'");
- }
- ReTtHtml($cid); //刷新標題分類
- echo"<script>alert('標題分類成功');window.close();</script>";
- exit();
- }
- $enews=$_POST['enews'];
- if(emptyempty($enews))
- {$enews=$_GET['enews'];}
- if($enews=='PushInfoToType')//推送標題分類
- {
- PushInfoToType($_POST,$logininid,$loginin);
- }
- $add='';
- //分類
- $cid=(int)$_GET['cid'];
- //欄目
- $classid=(int)$_GET['classid'];
- //ID
- $ids=RepPostStr($_GET['id'],1);
- if(!$ids)
- {
- echo"<script>alert('請選擇信息');window.close();</script>";
- exit();
- }
- //標題分類
- $cttidswhere='';
- $tts='';
- $caddr=$empire->fetch1("select ttids from zhuanti_enewsclassadd where classid='$classid'");
- $modid=7;
- if($caddr['ttids']!='-')
- {
- if($caddr['ttids']&&$caddr['ttids']!=',')
- {
- $cttidswhere=' and typeid in ('.substr($caddr['ttids'],1,-1).')';
- }
- $ttsql=$empire->query("select typeid,tname from zhuanti_enewsinfotype where mid='$modid'".$cttidswhere." order by myorder");
- while($ttr=$empire->fetch($ttsql))
- {
- $select='';
- $tts.="<option value='$ttr[typeid]'".$select.">$ttr[tname]</option>";
- }
- }
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>推送信息到標題分類</title>
- <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
- </head>
- <body>
- <table width="100%" border="0" cellspacing="1" cellpadding="3">
- <tr>
- <td>位置: 設置信息標題分類
- <div align="right"> </div></td>
- </tr>
- </table>
- <form name="form1" method="post" action="PushToInfoType.php">
- <table width="100%" border="0" cellspacing="1" cellpadding="3">
- <?=$ecms_hashur['form']?>
- <tr>
- <td>信息ID:<?=$ids?></td>
- </tr>
- </table>
- <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
- <tr class="header">
- <td width="100%" height="25"> <div align="center">所屬分類</div></td>
- </tr>
- <tr bgcolor="#FFFFFF" id="chsp">
- <td>
- <div align="center">
- <?=$tts?"<select name='cid'><option value='0'>標題分類</option>$tts</select>":""?>
- </div></td>
- </tr>
- <tr bgcolor="#FFFFFF">
- <td height="25" colspan="2"><div align="center">
- <input type="submit" name="Submit2" value="確定推送">
- <input type="button" name="Submit3" value="取消" onclick="window.close();">
- <input name="enews" type="hidden" id="enews" value="PushInfoToType">
- <input name="classid" type="hidden" id="classid" value="<?=$classid?>">
- <input name="ids" type="hidden" id="ids" value="<?=$ids?>">
- </div></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
- <?
- db_close();
- $empire=null;
- ?>

接下來我再說明下要修改的地方:
1、75行,select ttids from zhuanti_enewsclassadd,這里我的數據庫表前綴是zhuanti_,改成你自己的數據庫表前綴,比如帝國cms默認的數據庫表前綴phome_
2、83行,select typeid,tname from zhuanti_enewsinfotype,同上一步一樣,修改數據庫表前綴zhuanti_,改成你自己的數據庫表前綴。
3、76行,$modid
=7;這是數據庫表模型,如果是新聞數據庫表模型,這里改成1,可以在“系統”-“數據表與系統模型”-“管理數據表”查看ID號。
第二步,修改/e/data/html/list/listinfo.php文件,在</script>之前,加上下面的代碼:
第三步,在:<input type="button" name="Submit52" value="推送至專題" onClick="PushInfoToZt(this.form);">(大概396行)這行下增加:
- function PushToInfoType(form)
- {
- var id='';
- id=GetSelectId(form);
- if(id=='')
- {
- alert('請選擇要推送的信息');
- return false;
- }
- window.open('pushinfotype/PushToInfoType.php?<?=$ecms_hashur['ehref']?>&classid=<?=$classid?>&id='+id,'PushToInfoType','width=360,height=500,scrollbars=yes,left=300,top=150,resizable=yes');
- }
最后,保存后,到后臺看有沒有推送按鈕,測試是否成功
- <input type="button" name="Submit54" value="推送標題分類" onClick="PushToInfoType(this.form);">
點個贊! ()