DEDECMS后台文章管理中增加批量添加tag标签功能示例
<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";"><strong>需求背景:</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">之前发布了不少文章,后来发现之前的这些文章当时发布时都没有添加tag标签,然而现在需要都添加上tag标签,然而这个在默认的织梦后台是没办法批量实现的,只能一篇篇文章去修改。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";"><strong>思考: </strong>织梦原本的文章批量管理中有这么几项,看图:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;"><img style="max-width:100%!important;height:auto!important;" title="DEDECMS后台文章管理中增加批量添加tag标签功能示例" alt="DEDECMS后台文章管理中增加批量添加tag标签功能示例" src="https://zhuji.jb51.net/uploads/img/202305/1ac78ae2abf47cbebd4706d94713ca49.jpg"/></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
根据这个自动关键词、批量增加属性、批量删除属性这个思路来进行批量tag标签操作。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";"><strong>修改后的具体效果如下:</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;"><img style="max-width:100%!important;height:auto!important;" title="DEDECMS后台文章管理中增加批量添加tag标签功能示例" alt="DEDECMS后台文章管理中增加批量添加tag标签功能示例" src="https://zhuji.jb51.net/uploads/img/202305/18be9319d6455fee80a6de8a3a9f5578.jpg"/></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";"><strong>具体实现步骤:三步</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
1、打开dede/templets/content_list.htm,找到:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:xhtml;"> 删除属性</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
在他后边添加:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:xhtml;"> 修改tags标签</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
2、打开dede/js/list.js,在文件最后边添加:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:js;">/*批量修改文档*/
function EditArcs(jname,e,obj){
var qstr=getCheckboxItem();
if(qstr=='')
{
alert('必需选择一个或多个文档!');
return;
}
LoadQuickDiv(e, 'archives_do.php?dopost=batchEditArchives&qstr='+qstr+'&dojob='+jname+'&rnd='+Math.random(), 'tagsEditDlg', '450px', '160px');
ChangeFullDiv('show');
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
3.打开dede/archives_do.php,这个文件的最后四行是:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:xhtml;"> <br/></pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
替换成:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;"><?php
//AJAX 窗体结束
}
/*
* --------------------------------------------
* function batchEditArchives(){}
* 批量修改文档
* --------------------------------------------
* */
else if ($dopost == 'batchEditArchives')
{
if( !empty($aid) && empty($qstr) )
{
$qstr = $aid;
}
$dojobname = '修改TAG标签';
AjaxHead();
//输出AJAX可移动窗体
$divname = 'tagsEditDlg';
echo "\r\n";
echo "{$dojobname}\r\n";
echo " 标 签:(','号分隔,单个标签小于12字节) 文档ID: ExecuteNoneQuery("Delete From `js_taglist` where aid='$id' And tag like '$tag' ");
$dsql->ExecuteNoneQuery("Update `js_tagindex` set total=total-1 where tag like '$tag' ");
}
else
{
$dsql->ExecuteNoneQuery("Update `js_taglist` set `arcrank` = '$arcrank', `typeid` = '$typeid' where tag like '$tag' ");
}
}
}
ShowMsg("成功修改选中文档的tags标签!", $ENV_GOBACK_URL);
exit();
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁:
[1]