Change The Theme Dynamically

[font="Tahoma"]

I Want Change a part of the My Theme dynamically,

example:

replace in main.php —>> Phrase {menu} to a My Wiget when load site,

i override render() method in components/Controller.php




public function render($view,$data=null,$return=false)

    {

        if($this->beforeRender($view))

        {

            $output=$this->renderPartial($view,$data,true);

            if(($layoutFile=$this->getLayoutFile($this->layout))!==false)

                $output=$this->renderFile($layoutFile,array('content'=>$output),true);

 

            $this->afterRender($view,$output);

                        

            $output=$this->processOutput($output);

                        

                        $output = str_replace('{' . "menu" . '}', "wiget menu", $output);


            if($return)

                return $output;

            else

                echo $output;

        }

    }



But Cant replace Wiget to my Phrase,see error, can not convert to string,

[/font]