Function In Controller.php Not Accesibe From Sitecontroller

Hi All,

I just don’t know why I cannot call a method that I have added to Controller.php from a view, It’s so simple, but I guess I’m missing something, I get this error: SiteController and its behaviors do not have a method or closure named “createMultilanguageReturnUrl”.


class Controller extends CController


        public function __construct($id,$module=null){


	        Yii::app()->language = (isset($_GET['lang']))?$_GET['lang']:Yii::app()->language;



	public function createMultilanguageReturnUrl($lang='en'){

        $arr = array('lang'=>$lang);


	    if (count($_GET)>0){

	        $arr = $_GET;

	        $arr['lang']= $lang;


		return $this->createUrl('', $arr);




class SiteController extends Controller





<li><?php echo CHtml::link('English', $this->createMultilanguageReturnUrl('en')); ?></li>

<li><?php echo CHtml::link('Español', $this->createMultilanguageReturnUrl('es')); ?></li>

The curious thing is that if I create a new controller xyz extending from CController and then I extend SiteController from xyz, then I can reach that function in xyz controller.

Thanks in advance!

do u. checked with other function name? instead of that function.

Yes, I have tried with other function names with no succeed :(

First of all, it’s kinda bad practice to use controller functions from the view.

Second, check that no other file Controller.php exists.

You rock!!! :) I just don’t know why but… I’m using modules, so in each module there is a Controller.php in components folder, I have deleted all thoses Controller.php files, so every module controller extends from proteted/components/Controller.php and it WORKS! I wonder why, because I thought a module works as a independent application…

Ok, so in your opinion, what would be a good practice if I want to call a function visible for all controllers in my app?

Thanks for your comments ORey! Once again! I definetely will buy you a beer :)

It probably would not be delivered properly :D

Pressing the green "+" sign next to a helpful message is usually enough for me.