I’m quite new to Yii2 and I’m using Yii2-basic. I made an admin module with its CRUD feature (simple CMS). Let’s say in this case we’re talking about the “About-us” page. The admin module have the basic view pages : search,form, create,update,delete,view, index.
What is the best way to pass the view to the “frontend” where anyone can see from the admin module’s “backend” view? The view’s content of the admin’s module and the “frontend” is the same, only the layout is different. (Please keep in mind I’m using the the basic version so it doesn’t have actual front-end and backend tho )
I’m doing it this way :
In SiteController.php
use app\models\About;
.....
public function actionAbout()
{
$about = About::find()->one();
return $this->render('about', [
'model'=>$about
]);
}
.....
//do the same with the other controllers for other pages
.....
the view (about page’s “frontend”)
<?=$model->Content; ?>
It actually works, but I’m wondering if it’s the best way to do so. Or is it better to directly pass the view data from the admin module’s view to the ‘front-end’ view? If so, how to do that? Thank you in advance!