Title may be confusing, but here's explanation with code.
Based on some conditions,
I may call actionContact
even if user has called actionIndex
.
Solution:1
public function actionIndex()
{
$a = 5;
if($a == 5){
$this->actionContact();
}
else{
$this->render('index');
}
}
public function actionContact()
{
// Some codes
$this->render('contact');
}
Solution:2
public function actionIndex()
{
$a = 5;
if($a == 5){
// Repeat code from actionContact method
$this->render('contact');
}
else{
$this->render('index');
}
}
Solution:3 I can redirect to contact url.
I think, solution 1 works fine for me and I would prefer that. But since I am new to yii, I would like to know, if its the way to go ?