云狐网

您现在的位置是:首页 > 网站建设 > cms系统

cms系统

帝国cms7.5批量推送信息到分类标题插件

电脑迷 2022-04-04 23:46:45cms系统
帝国cms实现批量推送信息到标题分类,原理和推荐到专题一样,可以通过后台多选然后推送,这样可以提高后台编辑效率,不用一条条修改。YxL电脑_数码_手机应用问题解决的IT技术网站 - 云狐网
第一步,在e/admin/文件夹下新建一个文件夹pushinfotype,再新建一个php文件,命名为PushToInfoType.php。将下列代码粘贴到PushToInfoType.php。
  1. <?php 
  2. ini_set("display_errors""On"); 
  3. error_reporting(E_ALL | E_STRICT); 
  4. define('EmpireCMSAdmin','1'); 
  5. require("../../class/connect.php"); 
  6. require("../../class/db_sql.php"); 
  7. require("../../class/functions.php"); 
  8. require "../".LoadLang("pub/fun.php"); 
  9. require("../../class/t_functions.php"); 
  10. require("../../data/dbcache/class.php"); 
  11. require("../../data/dbcache/MemberLevel.php"); 
  12. require("../../class/chtmlfun.php"); 
  13. $link=db_connect(); 
  14. $empire=new mysqlquery(); 
  15. $editor=1; 
  16. //验证用户 
  17. $lur=is_login(); 
  18. $logininid=$lur['userid']; 
  19. $loginin=$lur['username']; 
  20. $loginrnd=$lur['rnd']; 
  21. $loginlevel=$lur['groupid']; 
  22. $loginadminstyleid=$lur['adminstyleid']; 
  23. //ehash 
  24. $ecms_hashur=hReturnEcmsHashStrAll(); 
  25.    
  26. //推送信息到标题分类 
  27. function PushInfoToType($add,$userid,$username){ 
  28.     global $empire,$dbtbpre,$lur,$class_r
  29.     $classid=(int)$add['classid']; 
  30.     $cid=(int)$add['cid']; 
  31.     $id=explode(',',$add[ids]); 
  32.     $count=count($id); 
  33.     //表名 
  34.     $tbname=''
  35.     if($classid
  36.     { 
  37.         $tbname=$class_r[$classid]['tbname']; 
  38.     } 
  39.     if(!$tbname
  40.     { 
  41.         printerror('ErrorUrl',''); 
  42.     } 
  43.     for($i=0;$i<$count;$i++) 
  44.         { 
  45.             $myid=intval($id[$i]); 
  46.             $empire->query("update {$dbtbpre}ecms_".$tbname." SET ttid='$cid' where classid='$classid' and id='$myid'"); 
  47.         } 
  48.     ReTtHtml($cid); //刷新标题分类 
  49.     echo"<script>alert('标题分类成功');window.close();</script>"
  50.     exit(); 
  51. $enews=$_POST['enews']; 
  52. if(emptyempty($enews)) 
  53. {$enews=$_GET['enews'];} 
  54. if($enews=='PushInfoToType')//推送标题分类 
  55.     PushInfoToType($_POST,$logininid,$loginin); 
  56. $add=''
  57. //分类 
  58. $cid=(int)$_GET['cid']; 
  59. //栏目 
  60. $classid=(int)$_GET['classid']; 
  61. //ID 
  62. $ids=RepPostStr($_GET['id'],1); 
  63. if(!$ids
  64.     echo"<script>alert('请选择信息');window.close();</script>"
  65.     exit(); 
  66. //标题分类 
  67. $cttidswhere=''
  68. $tts=''
  69. $caddr=$empire->fetch1("select ttids from zhuanti_enewsclassadd where classid='$classid'"); 
  70. $modid=7; 
  71. if($caddr['ttids']!='-'
  72.     if($caddr['ttids']&&$caddr['ttids']!=','
  73.     { 
  74.         $cttidswhere=' and typeid in ('.substr($caddr['ttids'],1,-1).')'
  75.     } 
  76.     $ttsql=$empire->query("select typeid,tname from zhuanti_enewsinfotype where mid='$modid'".$cttidswhere." order by myorder"); 
  77.     while($ttr=$empire->fetch($ttsql)) 
  78.     { 
  79.         $select=''
  80.         $tts.="<option value='$ttr[typeid]'".$select.">$ttr[tname]</option>"
  81.     } 
  82. ?> 
  83. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  84. <html> 
  85. <head> 
  86. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"
  87. <title>推送信息到标题分类</title> 
  88. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css"
  89. </head> 
  90.    
  91. <body> 
  92. <table width="100%" border="0" cellspacing="1" cellpadding="3"
  93.   <tr> 
  94.     <td>位置: 设置信息标题分类 
  95.       <div align="right"> </div></td> 
  96.   </tr> 
  97. </table> 
  98. <form name="form1" method="post" action="PushToInfoType.php"
  99.   <table width="100%" border="0" cellspacing="1" cellpadding="3"
  100.   <?=$ecms_hashur['form']?> 
  101.     <tr> 
  102.       <td>信息ID:<?=$ids?></td> 
  103.     </tr> 
  104.   </table> 
  105.   <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder"
  106.     <tr class="header"
  107.       <td width="100%" height="25"> <div align="center">所属分类</div></td> 
  108.     </tr> 
  109.     <tr bgcolor="#FFFFFF" id="chsp"
  110.       <td> 
  111.       <div align="center"
  112.     <?=$tts?"<select name='cid'><option value='0'>标题分类</option>$tts</select>":""?> 
  113.         </div></td> 
  114.     </tr> 
  115.     <tr bgcolor="#FFFFFF"
  116.       <td height="25" colspan="2"><div align="center"
  117.           <input type="submit" name="Submit2" value="确定推送"
  118.           &nbsp;&nbsp;<input type="button" name="Submit3" value="取消" onclick="window.close();"
  119.           <input name="enews" type="hidden" id="enews" value="PushInfoToType"
  120.           <input name="classid" type="hidden" id="classid" value="<?=$classid?>"
  121.           <input name="ids" type="hidden" id="ids" value="<?=$ids?>"
  122.         </div></td> 
  123.     </tr> 
  124.   </table> 
  125. </form> 
  126. </body> 
  127. </html> 
  128. <? 
  129. db_close(); 
  130. $empire=null; 
  131. ?> 
如图:YxL电脑_数码_手机应用问题解决的IT技术网站 - 云狐网
帝国cms7.5批量推送信息到分类标题插件

接下来我再说明下要修改的地方:YxL电脑_数码_手机应用问题解决的IT技术网站 - 云狐网

1、75行,select ttids from zhuanti_enewsclassadd,这里我的数据库表前缀是zhuanti_,改成你自己的数据库表前缀,比如帝国cms默认的数据库表前缀phome_YxL电脑_数码_手机应用问题解决的IT技术网站 - 云狐网

2、83行,select typeid,tname from zhuanti_enewsinfotype,同上一步一样,修改数据库表前缀zhuanti_,改成你自己的数据库表前缀。YxL电脑_数码_手机应用问题解决的IT技术网站 - 云狐网

3、76行$modid=7;这是数据库表模型,如果是新闻数据库表模型,这里改成1,可以在“系统”-“数据表与系统模型”-“管理数据表”查看ID号。YxL电脑_数码_手机应用问题解决的IT技术网站 - 云狐网

第二步,修改/e/data/html/list/listinfo.php文件,在</script>之前,加上下面的代码:YxL电脑_数码_手机应用问题解决的IT技术网站 - 云狐网
 YxL电脑_数码_手机应用问题解决的IT技术网站 - 云狐网

  1. function PushToInfoType(form) 
  2.         var id=''
  3.         id=GetSelectId(form); 
  4.         if(id==''
  5.         { 
  6.                 alert('请选择要推送的信息'); 
  7.                 return false; 
  8.         } 
  9.         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="Submit52" value="推送至专题" onClick="PushInfoToZt(this.form);">(大概396行)这行下增加:
  1. <input type="button" name="Submit54" value="推送标题分类" onClick="PushToInfoType(this.form);"
最后,保存后,到后台看有没有推送按钮,测试是否成功