url with module problems?

newbie, I am do some testing work these days. now I present the following code, hope somebody can help.

  1. the layout file which is protected/views/layouts/main.php,

    the testUrl set in TestModule.php is array(‘test/haha’);




$this->widget('zii.widgets.CMenu',array(

                                 'items'=>array(

                                          array('label'=>'Test', 'url'=>Yii::app()->getModule('test')->testUrl,),

                                        ),

                                        ));

echo $content;



  1. modules/test/controllers/HahaController.php, which renders the content from modules/test/views/haha/view.php



class HahaController extends CController

{

	public function actionIndex()

	{

		$this->render('view');

        }

}



Problem is: when I visit, I got an one item menu which displays Test(url to index.php?r=test/haha). I click Test, I got a right render, but if I try to click Test for the second time, the menu item Test url pointing to index.php?r=test/test/haha, denoting a haha action in test controller which is in test module, but actually, I

am requesting with a module(test) through one of its controllers(haha) with a default action which render a view.

The second click got me to somewhere else which is not my desire, how to solve this problem? Thanks in advance

precede your url with / like public $testUrl = array(’/test/haha’); or public $testUrl = ‘/test/haha’;

thank you, it works!

i would like to bring this topic up again. i have exactly the same problem, but i’m not happy with the solution.

i have a layout. this layout contains a menu and all the links are defined in a CMenu-like array. so usually the links look like this: index.php?r=controller/action

and now the problem: when i use a module (for example ‘backup’) i call the site with index.php?r=backup. and now all my links in the wrapped around layout looking like index.php?r=backup/controller/action.

how can i solve this problme without declaring each link seperatly?