文档说明:
在之前的文章中,小刘已经分享了如何在Typecho的前台实现文章/页面的编辑和删除操作。
文章发布后,有小伙伴问到我,这个删除万一手滑点到了,岂不是文章/页面立刻消失在了太平洋里。
于是,针对前台文章/页面删除的改进来了。
涉及文件:
usr/themes/当前正在使用的模版/post.php
usr/themes/当前正在使用的模版/page.php
修改说明:
1.搜索之前添加的的代码(post.php)
<?php Typecho_Widget::widget('Widget_Security')->to($security); ?>
<a href="<?php $security->index('/action/contents-post-edit?do=delete&cid='.$this->cid); ?>">删除文章</a>
2.将其替换为:
<?php Typecho_Widget::widget('Widget_Security')->to($security); ?>
<a href="<?php $security->index('/action/contents-post-edit?do=delete&cid='.$this->cid); ?>" onclick="javascript:return p_del()">删除文章</a>
<script>
function p_del() {
var msg = "您真的确定要删除吗?";
if (confirm(msg)==true){
return true;
}else{
return false;
}
}
</script>
3.搜索之前添加的的代码(page.php)
<?php Typecho_Widget::widget('Widget_Security')->to($security); ?>
<a href="<?php $security->index('/action/contents-page-edit?do=delete&cid='.$this->cid); ?>">删除页面</a>
4.将其替换为:
<?php Typecho_Widget::widget('Widget_Security')->to($security); ?>
<a href="<?php $security->index('/action/contents-page-edit?do=delete&cid='.$this->cid); ?>" onclick="javascript:return p_del()">删除页面</a>
<script>
function p_del() {
var msg = "您真的确定要删除吗?";
if (confirm(msg)==true){
return true;
}else{
return false;
}
}
</script>