Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

  • /protected
  • /themes
    • /mylayout
      • /layouts
        • main.php
        • column1.php
        • column2.php
      • /site
        • 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;

thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
580 views
Welcome To Ask or Share your Answers For Others

1 Answer

Like this

Yii::app()->controller->id

or

Yii::app()->getController()->getId()

http://www.yiiframework.com/doc/api/1.1/CApplication#getController-detail


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...