Yii:登录时更改标题中用户名的样式 [英] Yii: change the style of the username in header upon login
问题描述
我是一个yiibie.我想在登录时更改标题中用户名的样式.目前它以黑色显示,我希望它是斜体白色.下面是我的标题代码,请帮我解决这个问题,谢谢.
<div class="row logo"><div class="col-md-6"><br><a href='<?php echo Yii::app()->request->baseUrl;?>/emergency_response'><p>ERS.com</p></a><div class="col-md-6"><br><a href=''><p class='pull-right'>SignUp</p></a><!--在登录时在标题中显示用户名和注销按钮--><?phpif (Yii::app()->user->isGuest) {echo "<a href='".Yii::app()->request->baseUrl."/user/login'><p class='pull-right' style='margin-right: 12px'>登录</p></a>";}if (!Yii::app()->user->isGuest) {echo Yii::app()->user->name ." <a href='".Yii::app()->request->baseUrl ."/user/logout' style='color:blue';><p class='pull-right' style='margin-right: 12px'>注销</p></a>";}?>
</div><!--行在此结束--><div class="行导航"><br><div class="col-md-6 col-md-offset-3"><ul class="nav nav-pills"><li role="presentation"><a href="#"><p>Home</p></a></li><li role="presentation"><a href="#"><p>Ngo's</p></a></li><li role="presentation"><a href="#"><p>博客</p></a></li><li role="presentation"><a href="#"><p>Stories</p></a></li><li role="presentation"><a href="#"><p>视频</p></a></li><li role="presentation"><a href="#"><p>画廊</p></a></li><br>
</div><!--行在此结束-->
<!--标题在此结束--><!-- <div class="row"><?php $this->widget('zii.widgets.CMenu',array('项目'=>数组(array('label'=>'Home', 'url'=>array('/site/index')),array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),array('label'=>'Contact', 'url'=>array('/site/contact')),array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), '可见'=>!Yii::app()->user->isGuest)),));?></div>-->
试试这个
if (!Yii::app()->user->isGuest) {echo '<span style="color: white; font-style: italic;">'.Yii::app()->user->name ."</span> <a href='" .Yii::app()->request->baseUrl ."/site/logout' ><p class='pull-right' style='margin-right: 12px'>Logout</p></a>";}
i am a yiibie. i want to change the style of the username in the header upon login. Currently it is shown in black color, and i want it to be italic white. Down there is the code of my header, please help me with this, thankyou.
<div class="header">
<div class="row logo">
<div class="col-md-6">
<br>
<a href='<?php echo Yii::app()->request->baseUrl;?>/emergency_response'><p>ERS.com</p></a>
</div>
<div class="col-md-6">
<br>
<a href=''><p class='pull-right'>SignUp</p></a>
<!--to show the username and logout button in the header upon login-->
<?php
if (Yii::app()->user->isGuest) {
echo "<a href='".Yii::app()->request->baseUrl."/user/login'>
<p class='pull-right' style='margin-right: 12px'>LogIn</p>
</a>";
}
if (!Yii::app()->user->isGuest) {
echo Yii::app()->user->name . " <a href='".Yii::app()->request->baseUrl . "/user/logout' style='color:blue';>
<p class='pull-right' style='margin-right: 12px'>Logout</p>
</a>";
}
?>
</div>
</div><!--row ending here-->
<div class="row navigation">
<br>
<div class="col-md-6 col-md-offset-3">
<ul class="nav nav-pills">
<li role="presentation"><a href="#"><p>Home</p></a></li>
<li role="presentation"><a href="#"><p>Ngo's</p></a></li>
<li role="presentation"><a href="#"><p>Blogs</p></a></li>
<li role="presentation"><a href="#"><p>Stories</p></a></li>
<li role="presentation"><a href="#"><p>Videos</p></a></li>
<li role="presentation"><a href="#"><p>Gallery</p></a></li>
</ul>
<br>
</div>
</div><!--row ending here-->
</div> <!--header ending here-->
<!-- <div class="row">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
array('label'=>'Contact', 'url'=>array('/site/contact')),
array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
)); ?>
</div>-->
try this
if (!Yii::app()->user->isGuest) {
echo '<span style="color: white; font-style: italic;">'. Yii::app()->user->name . "</span> <a href='" .
Yii::app()->request->baseUrl .
"/site/logout' ><p class='pull-right' style='margin-right: 12px'>Logout</p></a>";
}
这篇关于Yii:登录时更改标题中用户名的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!