
author.php文件一般很少用到,先放出问题所在
访问用户a的个人主页,如果a发布过文章,则页面主页页面可以正常获取到a的邮箱,头像等相关信息
但是如果a没有发布过文章,则页面不能获取到相关个人信息,原因是获取并不到相关的用户id,但是浏览器的地址是带有用户的uid的,所以通过浏览器的地址,获取到用户uid,通过uid查询,反馈到页面中显示出用户相关信息
<?php
if(empty($this->author->uid)){
$str=$_SERVER["REQUEST_URI"];
if(preg_match('/\d+/',$str,$arr)){
$id=$arr[0];
if ($this->user->hasLogin()&&$this->user->uid==$id){$lock=0;}else{$lock=1;}
$info=userok($id);
$this->user->uid=$id;
$this->user->screenName=$info['screenName'];
$this->user->mail=$info['mail'];
$this->user->group=$info['group'];
}
}
?>
判断用户uid是否存在,如果不存在,则获取浏览器的地址,读取uid,进行查询
function userok($id){
$db = Typecho_Db::get();
$userinfo=$db->fetchRow($db->select()->from ('table.users')->where ('table.users.uid=?',$id));
return $userinfo;
}
显示代码:
<?php $this->user->mail(); ?>

文章评论
I enjoy you because of all of the effort on this blog. Betty delights in carrying out internet research and it's easy to see why. A lot of people hear all about the compelling form you convey advantageous guidance by means of the blog and attract contribution from other individuals about this area and my child has always been becoming educated a great deal. Enjoy the remaining portion of the new year. You're carrying out a brilliant job.
I am commenting to let you know of the fabulous encounter my cousin's daughter experienced reading your site. She even learned many issues, not to mention what it's like to have a wonderful giving mindset to have many people just grasp chosen grueling subject areas. You really exceeded our expectations. Many thanks for distributing the informative, healthy, educational and as well as easy thoughts on the topic to Jane.