DEDE编辑文章的地方加上 上一篇 下一篇 以及 删除 的小功能
有的时候觉得文章可以不用编辑了,想跳到下一篇,却要回到列表再选择,真麻烦
于是就弄了这个功能
在管理目录(默认是dede)的 article_edit.php 中的
$tables = GetChannelTable($dsql,$aid,’arc’);
后面添加
//小货添加,取得前后文章ID
$next = "Select ID From `{$tables[‘maintable’]}` where ID>’$aid’ order by ID asc ";
$pre = "Select ID From `{$tables[‘maintable’]}` 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?>
管理目录/action/article_eidt_action.php
$aTables = GetChannelTable($dsql,$channelid);
后添加
//小货添加,取得前后文章ID
$next = "Select ID From `{$aTables[‘maintable’]}` where ID>’$ID’ order by ID asc ";
$pre = "Select ID From `{$aTables[‘maintable’]}` 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 151行左右
else if($dopost=="delArchives")
的下面(约170行)
$dsql->Close();
的下面插入
if(!empty($nextid)) $ENV_GOBACK_URL = "archives_do.php?dopost=editArchives&aid=".$nextid;
再到下面的约186行
$win->AddHidden("aid",$aid);
后插入
$win->AddHidden("nextid",$nextid);