Action Chaining?

I am very new to Yii so I may be going around my problem the wrong way.

What is the best way to split an action into more actions?

e.g. For my gaming statistical website:

http://localhost/sta…d/1/list/weapon

I want it to use the MatchController with the show action, which then either does the 'weapon','team' or 'player' actions.

Thanks,

  • Twelve-60

Waoh, I swear I was in General Discussion? Feel free to move this thread… thanks,

  • Twelve-60

Are weapon/team/player really actions that can be directly accessed via /index.php/match/weapon ? If not, they are merely normal class methods, and you can invoke them in actionShow() as usual. If yes, you may call $this->run('weapon') to execute this action. However, this practice is not recommended.

Ok, I am just wondering on the conventional method of doing this.

Does this look right?



class MatchController {





	...





	public function actionShow()


	{


		$list = (isset($_GET['list']) ? $_GET['list'] : 'index');


		switch ($list)


		{


		case 'index':


			$this->matchIndex();


			break;


		case 'weapon':


			$this->matchWeapon();


			break;


		}


	}





	private function matchIndex()


	{


		$criteria = new CDbCriteria;


		$matches = Match::model()->findAll($criteria);


		$this->render('index', array(


			'matches'=>$matches,


		));


	}





	private function matchWeapon()


	{


		$criteria = new CDbCriteria;


		$weapons = Weapon::model()->findAll($criteria);


		$this->render('weapon', array(


			'weapons'=>$weapons,


		));


	}


}





Edit: weapon/team/player are not real actions, they are just different views really.

  • Twelve-60

Yeah, this should be fine. Just remember an action is supposed to be an interface for end users to call upon (in the form of controllerID/actionID).