YII获得当前控制器和方法

时间:2014-10-27 23:04:30   收藏:0   阅读:207

【如何获得当前控制器和方法】

控制器:$this -> id ;

方法:$this->action->id ;

这主要是用在视图中,进行高亮显示。

            <div id="mainNav" class="clearfix">
                <a href="./"   <?php if($this->id == 'index')echo "class='cur'"; ?>>首页<span></span></a>
                <a href="./index.php?r=goods/category" <?php if($this->id == 'goods')echo "class='cur'"; ?>>GSM手机<span></span></a>
                <a href="#">双模手机<span></span></a>
                <a href="#">汽车配件<span></span></a>
                <a href="#">优惠活动<span></span></a>
                <a href="#">留言板<span></span></a>
            </div>


评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!