Typecho主题前台实现删除文章功能.jpg
操作千万条,备份第一条,删文不谨慎,博主两行泪
将下面的代码放到 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>
点击按钮立即删除文章! 完善
上面的代码虽然实现了功能,但却泯灭了人性!下面我们完善下人性部分,代码改为
<?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>
这样弄好,点击按钮会弹出确认框,问其是否删除文章,用户确认后才会删除,比较符合操作习惯! 后语
post.php
页面成功删除文章后,因为文章不存在了,所以页面自动跳到了 404
页面,不知道怎么才能比较好的让它跳到首页QAQ
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有