织梦dedecms后台文章管理增加批量添加tag标签功能

织梦dedecms后台文章管理增加批量添加tag标签功能,具体操作如下:

1.打开dede/templets/content_list.htm,找到:

<a href="javascript:;" onClick="cAtts('attsDel',event,this)" class="coolbg">&nbsp;删除属性&nbsp;</a>

在后面添加

<a class="coolbg" onclick="EditArcs('tagsEdit',event,this)" href="javascript:;"> 修改tags标签 </a>

效果图

2.打开dede/js/list.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');

}

 

3.打开dede/archives_do.php,这个文件的最后四行是:

<?php

//AJAX窗体结束

}

?>

替换成

<?php

//AJAX 窗体结束

}

/*

* ——————————————–

* function batchEditArchives(){}

* 批量修改文档

* ——————————————–

* */

else if ($dopost == 'batchEditArchives')

{

if( !empty($aid) && empty($qstr) )

{

$qstr = $aid;

}

$dojobname = '修改TAG标签';

AjaxHead();

//输出AJAX可移动窗体

$divname = 'tagsEditDlg';

echo "<div class='title' onmousemove="DropMoveHand('{$divname}', 225);" onmousedown="DropStartHand();" onmouseup="DropStopHand();"> ";

echo " <div class='titLeft'>{$dojobname}</div> ";

echo " <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj("{$divname}");ChangeFullDiv("hide");' alt='封锁' title='封锁' /></div> ";

echo "</div> ";

echo "<form name='tagsEditDlgform' action='archives_do.php' method='post'> ";

echo "<input type='hidden' name='dopost' value='{$dojob}' /> ";

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'>&nbsp;标 签:</td>

<td class='bline'>

<input type='text' name='tags' id="tags" value='' />(','号分隔,单个标签小于12字节)

</td>

</tr>

<tr height='32'>

<td width="80" class='bline'>&nbsp;文档ID:</td>

<td class='bline'>

<input type='text' name='tmpids' value="<?php echo $qstr; ?>" style='width:310px;overflow:hidden;' />

</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" />

&nbsp;&nbsp;

<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 窗体结束

}

//修改标签结束

/*

* ——————————

* 修改标签详细操作

* function tagsEdit(){}

* ——————————

*

* */

elseif ($dopost == 'tagsEdit'){

//CheckPurview('a_Commend,sys_ArcBatch');

if( !empty($aid) && empty($qstr) )

{

$qstr = $aid;

}

if($qstr=='')

{

ShowMsg("参数无效!", $ENV_GOBACK_URL);

exit();

}

 

if(empty($tags))

{

ShowMsg("必需输入tags标签!", $ENV_GOBACK_URL);

exit();

}

$tags = str_replace(',', ',', $tags);

$tagss = explode(',',$tags);

if(empty($tagss)){

ShowMsg("必需输入tags标签!", $ENV_GOBACK_URL);

exit();

}

 

$arcids = ereg_replace('[^0-9,]','',ereg_replace('`', ',', $qstr));

$arcids_arr = explode(',', $arcids);

if (empty($arcids_arr)) {

ShowMsg("参数无效!", $ENV_GOBACK_URL);

exit();

}

 

foreach($arcids_arr as $id){

/*

* 处理修改后的Tag

*/

$oldtag = GetTags($id);

$oldtags = explode(',',$oldtag);

foreach($tagss as $tag)

{

$tag = trim($tag);

if(isset($tag[255]) || $tag!=stripslashes($tag))

{

continue;

}

if(!in_array($tag,$oldtags))

{

InsertOneTag($tag,$id);

}

}

foreach($oldtags as $tag)

{

if(!in_array($tag,$tagss))

{

$dsql->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();

}

原创文章,作者:忆夜,如若转载,请注明出处:https://98seo.com/wangzhan/20.html

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

微信
2022年网站改版,之前资源下载地址如有失效,请联系我。