北风吹乱 發表於 2024-8-1 00:00:00

DEDECMS后台文章管理中增加批量添加tag标签功能示例

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