帝国cms实现批量推送信息到标题分类,原理和推荐到专题一样,可以通过后台多选然后推送,这样可以提高后台编辑效率,不用一条条修改。
fU7电脑_数码_手机应用问题解决的IT技术网站seo – 云狐网


第一步,在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. } 
  52. $enews=$_POST[‘enews’]; 
  53. if(emptyempty($enews)) 
  54. {$enews=$_GET[‘enews’];} 
  55. if($enews==‘PushInfoToType’)//推送标题分类 
  56. { 
  57.     PushInfoToType($_POST,$logininid,$loginin); 
  58. } 
  59. $add=”; 
  60. //分类 
  61. $cid=(int)$_GET[‘cid’]; 
  62. //栏目 
  63. $classid=(int)$_GET[‘classid’]; 
  64. //ID 
  65. $ids=RepPostStr($_GET[‘id’],1); 
  66. if(!$ids) 
  67. { 
  68.     echo“<script>alert(‘请选择信息’);window.close();</script>”; 
  69.     exit(); 
  70. } 
  71. //标题分类 
  72. $cttidswhere=”; 
  73. $tts=”; 
  74. $caddr=$empire->fetch1(“select ttids from zhuanti_enewsclassadd where classid=’$classid'”); 
  75. $modid=7; 
  76. if($caddr[‘ttids’]!=‘-‘) 
  77. { 
  78.     if($caddr[‘ttids’]&&$caddr[‘ttids’]!=‘,’) 
  79.     { 
  80.         $cttidswhere=‘ and typeid in (‘.substr($caddr[‘ttids’],1,-1).‘)’; 
  81.     } 
  82.     $ttsql=$empire->query(“select typeid,tname from zhuanti_enewsinfotype where mid=’$modid'”.$cttidswhere.” order by myorder”); 
  83.     while($ttr=$empire->fetch($ttsql)) 
  84.     { 
  85.         $select=”; 
  86.         $tts.=“<option value=’$ttr[typeid]'”.$select.“>$ttr[tname]</option>”; 
  87.     } 
  88. } 
  89. ?> 
  90. <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”> 
  91. <html> 
  92. <head> 
  93. <meta http-equiv=“Content-Type” content=“text/html; charset=utf-8”> 
  94. <title>推送信息到标题分类</title> 
  95. <link href=“../adminstyle/<?=$loginadminstyleid?>/adminstyle.css” rel=“stylesheet” type=“text/css”> 
  96. </head> 
  97.    
  98. <body> 
  99. <table width=“100%” border=“0” cellspacing=“1” cellpadding=“3”> 
  100.   <tr> 
  101.     <td>位置: 设置信息标题分类 
  102.       <div align=“right”> </div></td> 
  103.   </tr> 
  104. </table> 
  105. <form name=“form1” method=“post” action=“PushToInfoType.php”> 
  106.   <table width=“100%” border=“0” cellspacing=“1” cellpadding=“3”> 
  107.   <?=$ecms_hashur[‘form’]?> 
  108.     <tr> 
  109.       <td>信息ID:<?=$ids?></td> 
  110.     </tr> 
  111.   </table> 
  112.   <table width=“100%” border=“0” align=“center” cellpadding=“3” cellspacing=“1” class=“tableborder”> 
  113.     <tr class=“header”> 
  114.       <td width=“100%” height=“25”> <div align=“center”>所属分类</div></td> 
  115.     </tr> 
  116.     <tr bgcolor=“#FFFFFF” id=“chsp”> 
  117.       <td> 
  118.       <div align=“center”> 
  119.     <?=$tts?“<select name=’cid’><option value=’0′>标题分类</option>$tts</select>”:“”?> 
  120.         </div></td> 
  121.     </tr> 
  122.     <tr bgcolor=“#FFFFFF”> 
  123.       <td height=“25” colspan=“2”><div align=“center”> 
  124.           <input type=“submit” name=“Submit2” value=“确定推送”> 
  125.           &nbsp;&nbsp;<input type=“button” name=“Submit3” value=“取消” onclick=“window.close();”> 
  126.           <input name=“enews” type=“hidden” id=“enews” value=“PushInfoToType”> 
  127.           <input name=“classid” type=“hidden” id=“classid” value=“<?=$classid?>”> 
  128.           <input name=“ids” type=“hidden” id=“ids” value=“<?=$ids?>”> 
  129.         </div></td> 
  130.     </tr> 
  131.   </table> 
  132. </form> 
  133. </body> 
  134. </html> 
  135. <? 
  136. db_close(); 
  137. $empire=null; 
  138. ?> 

如图:fU7电脑_数码_手机应用问题解决的IT技术网站seo – 云狐网

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

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

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

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

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

  1. function PushToInfoType(form) 
  2. { 
  3.         var id=”; 
  4.         id=GetSelectId(form); 
  5.         if(id==”) 
  6.         { 
  7.                 alert(‘请选择要推送的信息’); 
  8.                 return false; 
  9.         } 
  10.         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’); 
  11. } 

第三步,在:<input type=”button” name=”Submit52″ value=”推送至专题” onClick=”PushInfoToZt(this.form);”>(大概396行)这行下增加:

  1. <input type=“button” name=“Submit54” value=“推送标题分类” onClick=“PushToInfoType(this.form);”> 

最后,保存后,到后台看有没有推送按钮,测试是否成功

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。