当前位置:首页 > 文章 > 帝国CMS > 正文内容

帝国cms复制栏目时同时复制子栏目

3年前 (2022-10-21)帝国CMS3893

1、修改admin/addclass.php文件,大约在1153行,<input type="submit" name="Submit" value="提交">

的前面增加:<?php if($docopy) { ?><input type="checkbox" name="copyzlm" value="1" checked>复制子栏目&nbsp; <? }?>&nbsp;

2、修改admin/emsclass.php文件,大约在52行,将“AddClass($_POST,$logininid,$loginin);”修改为“cAddClass($_POST,$logininid,$loginin);”

3、将以下代码拷贝到class/userfun.php中。

function cAddClass($add,$userid,$username){

global $empire,$dbtbpre;

if($add[copyzlm]=='1'){

cAddClass1($add,$userid,$username);

$r = $empire->fetch1( "select * from {$dbtbpre}enewsclass order by classid desc limit 1" );

$bsql=$empire->query("select * from {$dbtbpre}enewsclass where bclassid='$add[classid]' and bclassid<>'0'");

while($br=$empire->fetch($bsql)){

$br[copyzlm]='1';

$br[bclassid]=$r[classid];

$br[pripath]=$r[classpath];

$br[classpath]=strrchr($br[classpath],'/');

if($br[islast]==0){

$brr=$br;

cAddClass($brr,$userid,$username);//递归

}else{

cAddClass1($br,$userid,$username,'1');

}

}

}else{

AddClass($add,$userid,$username);

}

}

//增加栏目

function cAddClass1($add,$userid,$username,$zz=0){

global $empire,$dbtbpre;

//增加外部栏目

if($add[ecmsclasstype])

{

AddWbClass($add,$userid,$username);

}

$add[classpath]=trim($add[classpath]);

if(!$add[classname]||!$add[classpath]||!$add[modid])

{

printerror("EmptyClass","");

}

if($add[islast]&&(!$add[newstempid]||!$add[listtempid]))

{

printerror("LastMustChange","");

}

//操作权限

CheckLevel($userid,$username,$classid,"class");

if($zz==0){

$add=DoPostClassVar($add);

}

//目录已存在

if(strchr($add[classpath],".")||strchr($add[classpath],"/")||strchr($add[classpath],""))

{

// printerror("badpath","");

}

$classpath=$add[pripath].$add[classpath];

if(file_exists("../../".$classpath))

{

printerror("ReClasspath","");

}

//取得表名

$tabler=GetModTable($add[modid]);

$tabler[tid]=(int)$tabler[tid];

//增加大栏目

if(!$add[islast])

{

if(empty($add[bclassid]))//主栏目

{

$sonclass="";

$featherclass="";

}

else//中级栏目

{

//取得上一级父栏目

$r=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");

if($r[islast])//是否终极栏目

{

printerror("BclassNotLast","");

}

if($r[wburl])

{

printerror("BclassNotWb","");

}

if(empty($r[featherclass]))

{

$r[featherclass]="|";

}

$featherclass=$r[featherclass].$add[bclassid]."|";

$sonclass="";

}

//建立目录

CreateClassPath($classpath);

$sql=$empire->query("insert into {$dbtbpre}enewsclass(bclassid,classname,is_zt,sonclass,lencord,link_num,newstempid,onclick,listtempid,featherclass,islast,classpath,classtype,newspath,filename,filetype,openpl,openadd,newline,hotline,goodline,classurl,groupid,myorder,filename_qz,hotplline,modid,checked,docheckuser,checkuser,firstline,bname,islist,searchtempid,tid,tbname,maxnum,checkpl,down_num,online_num,listorderf,listorder,reorderf,reorder,intro,classimg,jstempid,addinfofen,listdt,showclass,showdt,checkqadd,qaddlist,qaddgroupid,qaddshowkey,adminqinfo,doctime,classpagekey,dtlisttempid,classtempid,nreclass,nreinfo,nrejs,nottobq,ipath,addreinfo,haddlist,sametitle,definfovoteid,wburl,qeditchecked,wapstyleid,repreinfo,pltempid,cgroupid) values($add[bclassid],'$add[classname]',0,'$sonclass',$add[lencord],$add[link_num],$add[newstempid],0,$add[listtempid],'$featherclass',$add[islast],'$classpath','$add[classtype]','$add[newspath]',$add[filename],'$add[filetype]',$add[openpl],$add[openadd],$add[newline],$add[hotline],$add[goodline],'$add[classurl]',$add[groupid],$add[myorder],'$add[filename_qz]',$add[hotplline],$add[modid],$add[checked],$add[docheckuser],'$add[checkuser]',$add[firstline],'$add[bname]',$add[islist],$add[searchtempid],$tabler[tid],'$tabler[tbname]',$add[maxnum],$add[checkpl],$add[down_num],$add[online_num],'$add[listorderf]','$add[listorder]','$add[reorderf]','$add[reorder]','$add[intro]','$add[classimg]',$add[jstempid],$add[addinfofen],$add[listdt],$add[showclass],$add[showdt],$add[checkqadd],$add[qaddlist],'$add[qaddgroupid]',$add[qaddshowkey],$add[adminqinfo],$add[doctime],'$add[classpagekey]','$add[dtlisttempid]','$add[classtempid]',$add[nreclass],$add[nreinfo],$add[nrejs],$add[nottobq],'$add[ipath]',$add[addreinfo],$add[haddlist],$add[sametitle],$add[definfovoteid],'',$add[qeditchecked],$add[wapstyleid],'$add[repreinfo]','$add[pltempid]','$add[cgroupid]');");

$lastid=$empire->lastid();

//副表

$empire->query("replace into {$dbtbpre}enewsclassadd(classid,classtext) values('$lastid','".addslashes($add[classtext])."');");

TogNotReClass(1);

GetClass();

if($add[islist]==0||$add[islist]==2)

{

$classtemp=$add[islist]==2?GetClassText($lastid):GetClassTemp($add['classtempid']);

NewsBq($lastid,$classtemp,0,1);

}

DelListEnews();//删除缓存文件

GetSearch($add[modid]);//更新缓存

if($sql){

insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);//操作日志

// printerror("AddClassSuccess","AddClass.php?enews=AddClass&from=$add[from]");

}

else{

printerror("DbError","");

}

}

//增加终级栏目

else

{

//文件前缀

$add[filename_qz]=RepFilenameQz($add[filename_qz]);

if(empty($add[bclassid]))//主类别为终级栏目时

{

$sonclass="";

$featherclass="";

}

else//子栏目

{

//取得上一级父栏目

$r=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");

//是否终极类别

if($r[islast])

{

printerror("BclassNotLast","");

}

if($r[wburl])

{

printerror("BclassNotWb","");

}

if(empty($r[featherclass])){

$r[featherclass]="|";

}

$featherclass=$r[featherclass].$add[bclassid]."|";

$sonclass="";

}

//建立栏目目录

CreateClassPath($classpath);

$sql=$empire->query("insert into {$dbtbpre}enewsclass(bclassid,classname,sonclass,is_zt,lencord,link_num,newstempid,onclick,listtempid,featherclass,islast,classpath,classtype,newspath,filename,filetype,openpl,openadd,newline,hotline,goodline,classurl,groupid,myorder,filename_qz,hotplline,modid,checked,docheckuser,checkuser,firstline,bname,islist,searchtempid,tid,tbname,maxnum,checkpl,down_num,online_num,listorderf,listorder,reorderf,reorder,intro,classimg,jstempid,addinfofen,listdt,showclass,showdt,checkqadd,qaddlist,qaddgroupid,qaddshowkey,adminqinfo,doctime,classpagekey,dtlisttempid,classtempid,nreclass,nreinfo,nrejs,nottobq,ipath,addreinfo,haddlist,sametitle,definfovoteid,wburl,qeditchecked,wapstyleid,repreinfo,pltempid,cgroupid) values($add[bclassid],'$add[classname]','$sonclass',0,$add[lencord],$add[link_num],$add[newstempid],0,$add[listtempid],'$featherclass',$add[islast],'$classpath','$add[classtype]','$add[newspath]',$add[filename],'$add[filetype]',$add[openpl],$add[openadd],$add[newline],$add[hotline],$add[goodline],'$add[classurl]',$add[groupid],$add[myorder],'$add[filename_qz]',$add[hotplline],$add[modid],$add[checked],$add[docheckuser],'$add[checkuser]',$add[firstline],'$add[bname]',$add[islist],$add[searchtempid],$tabler[tid],'$tabler[tbname]',$add[maxnum],$add[checkpl],$add[down_num],$add[online_num],'$add[listorderf]','$add[listorder]','$add[reorderf]','$add[reorder]','$add[intro]','$add[classimg]',$add[jstempid],$add[addinfofen],$add[listdt],$add[showclass],$add[showdt],$add[checkqadd],$add[qaddlist],'$add[qaddgroupid]',$add[qaddshowkey],$add[adminqinfo],$add[doctime],'$add[classpagekey]','$add[dtlisttempid]','$add[classtempid]',$add[nreclass],$add[nreinfo],$add[nrejs],$add[nottobq],'$add[ipath]',$add[addreinfo],$add[haddlist],$add[sametitle],$add[definfovoteid],'',$add[qeditchecked],$add[wapstyleid],'$add[repreinfo]','$add[pltempid]','$add[cgroupid]');");

$lastid=$empire->lastid();

//副表

$empire->query("replace into {$dbtbpre}enewsclassadd(classid,classtext) values('$lastid','".addslashes($add[classtext])."');");

//修改父栏目的子栏目

if($add[bclassid])

{

$b_r=$empire->fetch1("select sonclass,featherclass from {$dbtbpre}enewsclass where classid='$add[bclassid]'");

if(empty($b_r[sonclass]))

{

$b_r[sonclass]="|";

}

$new_sonclass=$b_r[sonclass].$lastid."|";

$update=$empire->query("update {$dbtbpre}enewsclass set sonclass='$new_sonclass' where classid='$add[bclassid]'");

//更改父类别的父栏目的子栏目

$where=ReturnClass($b_r[featherclass]);

if(empty($where)){

$where="classid=0";

}

$bsql=$empire->query("select sonclass,classid from {$dbtbpre}enewsclass where ".$where);

while($br=$empire->fetch($bsql))

{

if(empty($br[sonclass]))

{

$br[sonclass]="|";

}

$new_sonclass=$br[sonclass].$lastid."|";

$update=$empire->query("update {$dbtbpre}enewsclass set sonclass='$new_sonclass' where classid='$br[classid]'");

}

}

DelListEnews();//删除缓存文件

TogNotReClass(1);

GetClass();

GetSearch($add[modid]);//更新缓存

if($sql){

insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);//操作日志

// printerror("AddLastClassSuccess","AddClass.php?enews=AddClass&from=$add[from]");

}

else{

printerror("DbError","history.go(-1)");

}

}

}

上面代码,只有函数cAddClass是我写的,下面的函数cAddClass是对wf原来的函数AddClass稍作修改拷贝过来的,放到userfun.php文件中目的是不对classfun.php文件作改动。

好了,复制栏目试试看

扫描二维码推送至手机访问。

版权声明:本文由蓝博发布,如需转载请注明出处。

本文链接:https://www.blueboss.cn/p/505.shtml

“帝国cms复制栏目时同时复制子栏目” 的相关文章

帝国CMS列表页判断是否有标题图片没有则显示指定的图片

帝国CMS列表页判断是否有标题图片没有则显示指定的图片

帝国CMS列表页模板里面怎么判断文章是否有标题图片,如果没有图片就调用显示默认或者指定的一张图片!   第一种方法、用php判断:   ①、复制以下代码带到“列表内容模板” if(empty($r[titlepic])) { $pic=''; } else { $pic='<img src=...

帝国CMS中#091;!--no.num--]标签的用法分析

帝国CMS中#091;!--no.num--]标签的用法分析

帝国CMS [!--no.num--] 标签用法: 帝国CMS[!--no.num--] 指定从某一数字开始显示 代码如下: <?=$bqno+5?> 帝国CMS[!--no.num--] 输出效果为 1 2 3 4 5 6 7 8...样式 代码如下: <?=$bqno?&g...

帝国CMS结合项提示您来自的链接不存在

帝国CMS结合项提示您来自的链接不存在

帝国CMS结合项提示"您来自的链接不存在"的解决方法。具体方法如下: 打开e/class/userfun.php 将global $public_r; 改成 global $public_r,$navclassid; if($_GET['classid'])   {  $classid=RepPo...

帝国CMS内容页调用指定ID的文章可以指定多篇

帝国CMS内容页调用指定ID的文章可以指定多篇

帝国CMS内容页中调用多篇指定id文章的方法,下面一起来学习学习吧: 大概的思路是: 新建1个产品文章字段,这样的话,每个产品里面都可以填写不同的产品id,然后在模板里面调用出来即可。 下面附上内容页模板里面调用多篇指定文章id的php代码: <?php $sql='id in ('.$na...

帝国CMS用灵动标签调用简介截取字数

帝国CMS用灵动标签调用简介截取字数

帝国CMS灵动标签调用文章缩略图的标签写法: <?=$bqr[smalltext]?> <?=esub($bqr[smalltext],50)?> (上面标签注释:该标签可限制内容简介显示的字数,举例中的50表示显示50个字符,算城成是汉字就是25个字,大家可以根据自己的...

帝国CMS灵动标签调用副表字段内容

帝国CMS灵动标签调用副表字段内容

在灵动标签循环内用SQL读取副表内容。下面以读取新闻副表中的newstext字段为例: [e:loop={0,1,3,0}] <?php $fr=$empire->fetch1("select newstext from {$dbtbpre}ecms_news_data_{$bqr[s...