typecho内置有这方面的功能,也就是<?php $this->remember(''); ?>
<?php $this->remember('author'); ?>
= 账号信息
<?php $this->remember('mail'); ?>
= 邮件信息
也就是typecho提交信息后会留下cookies值,<?php $this->remember(''); ?>
就是用来获取cookies的账号信息
那么,也就可以这样
<?php if($this->user->hasLogin()): ?>
<div class="hasLogin">
<?php $email=$this->user->mail; $imgUrl = getGravatar($email);echo '<img src="'.$imgUrl.'" width="22px" height="22px" class="avatar hasLogin-author" >'; ?><?php $this->user->screenName(); ?>. <a href="<?php $this->options->logoutUrl(); ?>" title="Logout">退出 »</a>
</div>
<?php else: ?>
<?php if($this->remember('author',true) != "" && $this->remember('mail',true) != "") : ?>
<div class="hasLogin comm_on" id="comm_on">
<?php $this->remember('author'); ?>. <a href="javascript:;" onclick="bian()" title="Logout" >编辑资料? »</a>
<script>function bian()
{ var oBox = document.getElementById("comm_off"); var oBox1 = document.getElementById("comm_on"); oBox.style.display= "block"; oBox1.style.display= "none";}</script>
</div>
<ul class="ident" id="comm_off">
<li>
<input type="text" name="author" placeholder="昵称*" value="<?php $this->remember('author'); ?>">
</li>
<li>
<input type="mail" name="mail" placeholder="邮件*" value="<?php $this->remember('mail'); ?>">
</li>
</ul>
<?php else : ?>
<ul class="ident">
<li>
<input type="text" name="author" placeholder="昵称*" value="<?php $this->remember('author'); ?>">
</li>
<li>
<input type="mail" name="mail" placeholder="邮件*" value="<?php $this->remember('mail'); ?>">
</li>
</ul>
<?php endif; ?><?php endif ; ?>
以上的大概思路是
1,判断是否注册用户,如果是注册用户,直接显示账号信息
2,只是游客用户,判断用户是否有过cookies的信息,如果有,则不需要填入昵称和邮件,如果用户想改变昵称邮箱,可以直接点击编辑资料,进行修改
3,如果是新的游客,没有留言回复过,则显示正常的初步昵称和邮件地址