您当前的位置:首页 > 网络教程 > 帝国CMS教程

12.7 帝国cms批量推送信息到标题分类

1、将下列代码存放到e/admin/pushinfotype/文件夹下,并且命名为:PushToInfoType.php,注意要修改75行,83行的数据库表前缀zhuanti_,76行模型id号

<?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(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"<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="确定推送">
          &nbsp;&nbsp;<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;
?>


如图:

帝国cms批量推送信息到标题分类
2、修改/e/data/html/list/listinfo.php文件

在</script>之前,加上下面的代码:

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');
}

3、在:<input type="button" name="Submit52" value="推送至专题" onClick="PushInfoToZt(this.form);">(大概396行)这行下增加:

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

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

帝国cms批量推送信息到标题分类

原文章来自(本文有修改):http://bbs.phome.net/showthread-31-353009-6.html

你觉得文章内容怎么样

阿里云代金券 100 云产品通用

有效期30天 首购用户

立即领取
阿里云代金券 100 云产品通用

有效期30天 复购+升级

立即领取