DEDE5.3编辑文章的地方加上 上一篇 下一篇 等

时间: 2009-10-06 / 分类: dedecms / 浏览次数: 4,325 views / 0个评论 发表评论

有的时候觉得文章可以不用编辑了,想跳到下一篇,却要回到列表再选择,真麻烦
于是就弄了这个功能

在管理目录(默认是dede)的 article_edit.php 中的

42行?$tags = GetTags($aid);?? 后面添加

//小货添加,取得前后文章ID
$next = “Select ID From `dede_archives` where ID>’$aid’? order by ID asc “;
$pre = “Select ID From `dede_archives` where ID<‘$aid’? order by ID desc “;
$nextRow = $dsql->GetOne($next);
$preRow = $dsql->GetOne($pre);
if ($nextRow[‘ID’]>0){
$next=”<a href=’archives_do.php?dopost=editArchives&aid=”.$nextRow[‘ID’].”‘>下一篇</a>”;
}else{
$next=”没有了”;
}
if ($preRow[‘ID’]>0){
$pre=”<a href=’archives_do.php?dopost=editArchives&aid=”.$preRow[‘ID’].”‘>上一篇</a>”;
}else{
$pre=”没有了”;
}
//取得前后ID结束
//创建删除连接
$del=”<a href=’archives_do.php?dopost=delArchives&aid=”.$aid.”&qstr=”.$aid.”&nextid=”.$nextRow[‘ID’].”‘>删除</a>”;
//删除连接创建完毕
//创建总连接
$addlink=$del.”??? “.$pre.”??? “.$next;
//小货添加结束

然后在编辑管理目录下的templets下的article_edit.htm文件
在需要放的地方 放上
?

<?php echo $addlink?>

例如:把article_edit.htm? 349行到357行修改为
????????? <td width=”83%”><table width=”414″ border=”0″ cellspacing=”0″ cellpadding=”0″>
????????????? <tr>
??????????????? <td width=”115″><input name=”imageField” type=”image” src=”img/button_ok.gif” width=”60″ height=”22″

class=”np” border=”0″ style=”cursor:pointer”></td>
??????????????? <td width=”99″>
??????????????? ?<img src=”img/button_reset.gif” width=”60″ height=”22″ border=”0″ onClick=”location.reload();”

style=”cursor:pointer”>
??????????????? </td>
????<td width=”200″>
???? <?php echo $addlink?>
???? </td>
????????????? </tr>
??????????? </table></td>
变化一下,继续增加功能,在编辑完以后出现的信息中也可以选

在管理目录(默认是dede)的 article_edit.php 中的 225行 后添加(也就是?? //生成HTML?? 之前)

//小货添加,取得前后文章ID
$next = “Select ID From `dede_archives` where ID>’$id’? order by ID asc “;
$pre = “Select ID From `dede_archives` where ID<‘$id’? order by ID desc “;
$nextRow = $dsql->GetOne($next);
$preRow = $dsql->GetOne($pre);
if ($nextRow[‘ID’]>0){
$next=”<a href=’archives_do.php?dopost=editArchives&aid=”.$nextRow[‘ID’].”‘>下一篇</a>”;
}else{
$next=”没有了”;
}
if ($preRow[‘ID’]>0){
$pre=”<a href=’archives_do.php?dopost=editArchives&aid=”.$preRow[‘ID’].”‘>上一篇</a>”;
}else{
$pre=”没有了”;
}
//取得前后ID结束
再到下面的
<a href=’../catalog_main.php’><u>网站栏目管理</u></a>

后添加
?
“.$pre.”
?
“.$next.”

当然,你觉得查数据库太浪费资源,可以在上面的文件中直接POST上下篇的ID

?

很好,我们再研究一下删除文章后如何跳转到下一篇

找到archives_do.php 220行左右

else if($dopost==”delArchives”)
的下面(约255行)
ShowMsg(“成功删除指定的文档!”,$ENV_GOBACK_URL);?
之前插入
if(!empty($nextid)) $ENV_GOBACK_URL = “archives_do.php?dopost=editArchives&aid=”.$nextid;
269行
??? $win->AddHidden(“aid”,$aid);

后插入
$win->AddHidden(“nextid”,$nextid);

因为5。3开启了回收站功能,所以现在上下篇会连回收站中的内容也当作正常内容一起查询

所以建议不要开启回收站

发表评论

您的昵称 *

您的邮箱 *

您的网站