在 Yii 中获取当前控制器 ID [英] Getting Current Controller ID in Yii

查看:24
本文介绍了在 Yii 中获取当前控制器 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取处理当前操作的当前控制器名称.但在我的情况下我将在我的布局文件中的 main.php 中查找当前控制器.

I want to get the current controller name that handles the current action. but the in my case I will look for the current controller in my main.php in my layout files.

这是我的目录结构的小视图,让您了解我的布局文件在哪里以及我将在其中放置代码以搜索控制器名称的文件

this is my small view of my directory structure to give you an idea where is my layout files and the file where i will put my codes in searching of my controller name

  • /受保护
  • /主题
    • /mylayout
      • /布局
        • ma​​in.php
        • column1.php
        • column2.php
        • index.php

        这可能吗?我正在尝试以下代码,但我没有得到我当前的控制器名称...

        Is this possible? im trying the following codes but i failed to get my current controller name...

        echo Yii::app()->controller->getId;
        echo Yii:app()->getController->id;
        echo Yii:app()->controller->uniqueID;
        

        谢谢

        推荐答案

        getUniqueId();?>

        这将显示当前控制器

        这篇关于在 Yii 中获取当前控制器 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆