dsxon40042 2015-11-13 19:35
浏览 32
已采纳

Yii:登录时更改标题中用户名的样式

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>-->
  • 写回答

1条回答 默认 最新

  • dougan7523 2015-11-13 19:39
    关注

    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>";
            }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?