互联网知识

精准传达 • 价值共享

洞悉互联网前沿资讯,探寻网站营销规律

查看其它板块

织梦网站后台增加复制文章文档的功能

作者:狐灵科技 | 2020-02-05 20:28 |点击:

起因:

因为狐灵的客户 在我们公司做了一个中文网站 突然突然想在增加一个外贸站 而且是以二级目录/en 的形式

客户的产品有几千个 非常之多  每篇文章发布起来是非常麻烦的  所以导致我们想增加文章复制功能 只把标题改下 提高效率

下面说织梦网站后台增加复制文档的功能的详细说明 另“附上修改的文件打包


效果图如下:

复制文档功能截图

Dedecms织梦后台增加复制文档
的功能步骤如下

一、打开templets下的content_list.htm 找到

<a href="javascript:;" onClick="moveArc(event,this,<?php echo (empty($channelid) ? 0 : $channelid); ?>)" class="coolbg">&nbsp;移动&nbsp;</a>

在这一行的下方添加:

<a href="javascript:;" onClick="copyArc(event,this,<?php echo (empty($channelid) ? 0 : $channelid); ?>);" class="coolbg">&nbsp;复制&nbsp;</a>

 

二、打开dede/js/list.js 找到


function moveArc(e, obj, cid)

在它的上方添加这个函数
 

  1. function copyArc(e, obj, cid){
        var qstr=getCheckboxItem();
        if(qstr=='')
        {
            alert('必须选择一个或多个文档!');
            return;
        }
        LoadQuickDiv(e, 'archives_do.php?dopost=copyArchives&qstr='+qstr+'&channelid='+cid+'&rnd='+Math.random(), 'copyArchives', '450px', '180px');
        ChangeFullDiv('show');
    }
     


 

三、打开 dede/archives_do.php 找到

else if($dopost=='return')



在它的上方添加如下代码:


  1. elseif ($dopost == 'copyArchives') {
        CheckPurview('sys_ArcBatch');
        if (empty($totype)) {
            require_once(DEDEINC . '/typelink.class.php');
            if (!empty($aid) && empty($qstr)) $qstr = $aid;
     
            AjaxHead();
            $channelid = empty($channelid) ? 0 : $channelid;
            $tl = new TypeLink($aid);
            $typeOptions = $tl->GetOptionArray(0, $admin_catalogs, $channelid);
            $typeOptions = "<select name='totype' style='width:90%'>
            <option value='0'>请选择复制到的位置...</option>
            $typeOptions
            </select>";
     
            //输出AJAX可移动窗体
            $divname = 'copyArchives';
            echo "<div class='title' onmousemove="DropMoveHand('{$divname}', 225);" onmousedown="DropStartHand();" onmouseup="DropStopHand();"> ";
            echo "    <div class='titLeft'>复制文档</div> ";
            echo "    <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj("{$divname}");ChangeFullDiv("hide");' 关闭' title='关闭' /></div> ";
            echo "</div> ";
            echo "<form name='quickeditform' action='archives_do.php' method='post'> ";
            echo "<input type='hidden' name='dopost' value='{$dopost}' /> ";
            echo "<input type='hidden' name='qstr' value='{$qstr}' /> ";
            echo "<table width='100%' style='margin-top:6px;z-index:9000;'> ";
            ?>
            <tr height='28'>
                <td width="80" class='bline'> 目标栏目:</td>
                <td class='bline'>
                    <?php echo $typeOptions; ?>
                </td>
            </tr>
            <tr height='32'>
                <td width="80" class='bline'> 文档ID:</td>
                <td class='bline'>
                    <input type='text' name='tmpids' value="<?php echo $qstr; ?>" style='width:310px;overflow:hidden;'/>
                    <br/>
                    复制到的目标栏目必须和选定的文档频道类型一致,否则程序会自动勿略不符合的文档。
                </td>
            </tr>
            <tr height='32'>
                <td colspan='2' align='center' style='padding-top:12px'>
                    <input name="imageField" type="image" src="images/button_ok.gif" width="60" height="22" class="np"
                           border="0" style="cursor:pointer"/>
                      
                    <img src="images/button_back.gif" width="60" height="22" border="0"
                         onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' style="cursor:pointer"/>
                </td>
                </td>
            </tr>
            </table>
            </form>
            <?php
            //AJAX窗体结束
        } else {
            $totype = preg_replace("#[^0-9]#", '', $totype);
            $typeInfos = $dsql->GetOne("SELECT tp.channeltype,tp.ispart,tp.channeltype,ch.maintable,ch.addtable,ch.issystem FROM `dede_arctype` tp LEFT JOIN `dede_channeltype` ch on ch.id=tp.channeltype WHERE tp.id='$totype' ");
            $idtype = "id";
            if (!is_array($typeInfos)) {
                ShowMsg('参数错误!', '-1');
                exit();
            }
            if ($typeInfos['ispart'] != 0) {
                ShowMsg('文档保存的栏目必须为最终列表栏目!', '-1');
                exit();
            }
            if (empty($typeInfos['addtable'])) {
                $typeInfos['maintable'] = '`dede_archives`';
            }
            //增加单表模型判断
            if ($typeInfos['issystem'] == -1) {
                $typeInfos['maintable'] = $typeInfos['addtable'];
                $idtype = "aid";
            }
            $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
            $arc = '';
            $j = 0;
            $okids = array();
            $dsql->SetQuery("SELECT {$idtype},typeid FROM `{$typeInfos['maintable']}` WHERE {$idtype} in($arcids) AND channel='{$typeInfos['channeltype']}' ");
            $dsql->Execute();
            while ($row = $dsql->GetArray()) {
                if ($row['typeid'] != $totype) {
                    
                    $dsql->ExecuteNoneQuery("insert into `dede_arctiny` (typeid,typeid2,arcrank,channel,senddate,sortrank,mid) select typeid,typeid2,arcrank,channel,senddate,sortrank,mid from `dede_arctiny` where id='{$row[$idtype]}'");
                    
                    $xid = $dsql->GetLastID();
                    
                    $dsql->ExecuteNoneQuery("insert into `{$typeInfos['maintable']}`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,keywords,lastpost,scores,goodpost,badpost,voteid,notpost,description,filename,dutyadmin,tackid,mtype,weight) select case when id>'0' then '$xid'  else '' end, case when typeid>'0' then '$totype'  else '' end,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,keywords ,lastpost,scores,goodpost,badpost,voteid,notpost,description,filename,dutyadmin,tackid,mtype,weight from `{$typeInfos['maintable']}` WHERE id='{$row[$idtype]}' ");
                    
                    $dsql->ExecuteNoneQuery("insert into `{$typeInfos['addtable']}`(aid,typeid,body,redirecturl,templet,userip) select case when aid>'0' then '$xid'  else '' end,$totype,body,redirecturl,templet,userip from `{$typeInfos['addtable']}` WHERE aid='{$row[$idtype]}' ");
                    
                    $okids[] = $row[$idtype];
                    $j++;
                }
            }
     
            
        UpDateCatCache();
        $sql = " TRUNCATE TABLE `dede_arctiny`";
        $dsql->ExecuteNoneQuery($sql);
        
        //导入普通模型微数据
        $sql = "INSERT INTO `dede_arctiny`(id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid)  
                SELECT id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid FROM `dede_archives` ";
        $dsql->ExecuteNoneQuery($sql);
        
        //导入单表模型微数据
        $dsql->SetQuery("SELECT id,addtable FROM `dede_channeltype` WHERE id < -1 ");
        $dsql->Execute();
        $doarray = array();
        while($row = $dsql->GetArray())
        {
            $tb = str_replace('dede_', $cfg_dbprefix, $row['addtable']);
            if(empty($tb) || isset($doarray[$tb]) )
            {
                continue;
            }
            else
            {
                $sql = "INSERT INTO `dede_arctiny`(id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid)  
                        SELECT aid, typeid, 0, arcrank, channel, senddate, 0, mid FROM `$tb` ";
                $rs = $dsql->executenonequery($sql);
                $doarray[$tb]  = 1;
            }
        }
            //更新HTML
            foreach ($okids as $aid) {
                $arc = new Archives($aid);
                $arc->MakeHtml();
            }
            ShowMsg("成功复制 $j 个文档!", $ENV_GOBACK_URL);
            exit();
        }
     


然后就完成了织梦 增加复制文章的方法


如果提示成功复制0个文档 说明你复制错了 不能同栏目之间复制 


另外注意的是 完成了以上操作 只能文档复制 不能图集  想要图集复制 找到这个文件 
dede/ templets/ content_i_list.htm 

找到 

  1. <a href="javascript:;" onClick="moveArc(event,this,<?php echo (empty($channelid) ? 0 : $channelid); ?>)" class="coolbg">&nbsp;移动&nbsp;</a>

在他的下面复制
 
  1. <a href="javascript:;" onClick="copyArc(event,this,<?php echo (empty($channelid) ? 0 : $channelid); ?>);" class="coolbg">&nbsp;复制&nbsp;</a>

完成

图集只能复制文章内容 不能复制图集图片

如果嫌麻烦或者担心改错 可以下载懒人包进行替换

 点击图标下载(注意更改dede默认目录)



如没特殊注明,文章均为狐灵科技原创,转载请注明  https://www.hulingweb.cn/hulianwang/449.html
多一份免费策划方案,总有益处。

请直接添加技术总监微信联系咨询

网站设计 品牌营销

多一份参考,总有益处

联系狐灵科技,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:023-68168040 / 大客户专线:15523356218