Typecho前台添加编辑文章链接
AI摘要:本文介绍如何在Typecho前台添加编辑文章链接,通过判断用户登录状态和权限,为管理员提供直接编辑文章的便捷入口,避免频繁进入后台操作的麻烦。
每次编辑文章都要跑到后台,点击管理文章然后编辑,挺不舒服的,于是动手改了下代码。
其实代码也不难,首先就是判断是否登陆,然后再判断权限,官方有具体的权限控制文档。
<?php if($this->user->hasLogin()):?>
<?php if($this->user->pass('administrator','true')):?>
<a href="/admin/write-post.php?cid=<?php echo $this->cid;?>" target="_blank">编辑文章</a>
<?php endif;?>
<?php endif;?>