Yes, I know I am diving right into the deep end, however, I’m up for the challenge, just need some assistance to get going.
I’ve gone through the tutorial on OOP on the PHP website and I think I have a decent grasp of it. Still, putting everything together is a bit of challenge. I have absorbed so much information in a very short amount of time and it’s rather jumbled and unorganized (I’ve read both guides of Yii, 1.1 and 2.0, all of w3schools, etc.). And I have written my own code. I created my own login page and a couple javascript driven pages, but neither using OOP (didn’t really know what OOP was until I started working with Yii).
I REALLY like Yii. I’ve already tweaked a few things to my liking and I’d really like to continue on this path.
Anyway, getting back on topic. I did what was suggested and modified a few things but I need to understand/fix/address something before going further.
I created a BaseController and extended SiteController from it as previously suggested. And I added this piece of code to it.
public function init()
{
if (Yii::$app->user->userStatus) {
return $this->render('about');
}
}
Very simple piece, that doesn’t do much on its own. You may notice the “userStatus” function there. I added these lines to yii\web\user.php.
public function getUserStatus(){
return TRUE;
}
As you can see, nothing too special here. I’m just trying to get the redirect to work.
Let’s say I click on the homepage link, what’s happening is that (from logs), “about” IS being rendered, but then, immediately afterwards, SiteController is invoked and the index is rendered. I’m obviously missing something here, but I’m not sure what.
Some help would be appreciated.