![图片[1]-帝国cms7.5批量推送信息到分类标题插件-HostJL-VPS主机交流](https://www.hostjl.com/wp-content/hctimg/20230610/f50626648c16365961dda83679e0e06c355.jpg)
帝国cms实现批量推送信息到标题分类,原理和推荐到专题一样,可以通过后台多选然后推送,这样可以提高后台编辑效率,不用一条条修改。下面是青青模板网根据帝国cms论坛上sbgl发布的插件,进行了优化整理,供大家参考。
第一步,在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;$iquery("update {$dbtbpre}ecms_".$tbname." SET ttid='$cid' where classid='$classid' and id='$myid'");
}
ReTtHtml($cid); //刷新标题分类
echo"alert('标题分类成功');window.close();";
exit();
}
$enews=$_POST['enews'];
if(empty($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"alert('请选择信息');window.close();";
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.="$ttr[tname]";
}
}
?>
推送信息到标题分类
<link href="../adminstyle//adminstyle.css" rel="stylesheet" type="text/css">
| 位置: 设置信息标题分类
|
| 信息ID: |
| 所属分类 |
|
|
<?=$tts?"标题分类$tts":""?>
|
|
<input name="classid" type="hidden" id="classid" value="">
<input name="ids" type="hidden" id="ids" value="">
|
|
如图:

接下来我再说明下要修改的地方:
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文件,在之前,加上下面的代码:
function PushToInfoType(form)
{
var id='';
id=GetSelectId(form);
if(id=='')
{
alert('请选择要推送的信息');
return false;
}
window.open('pushinfotype/PushToInfoType.php?&classid=&id='+id,'PushToInfoType','width=360,height=500,scrollbars=yes,left=300,top=150,resizable=yes');
}第三步,在:(大概396行)这行下增加:
最后,保存后,到后台看有没有推送按钮,测试是否成功
以上就是关于帝国cms插件中"帝国cms7.5批量推送信息到分类标题插件"的全部内容,如果有遇到帝国cms插件其他问题的,可以在评论留言,或者加微信咨询。










暂无评论内容