Yii2 Advanced help

Hi, I’m pretty new to yii and what i mean by that is I only started using it last week. I have gone through some tutorials and been learning it. So I have my frontend set up and my backend set up with a posts table. This may seem like a noob question but in the tutorials I have been looking at none of them tell you or even mention how to display the posts table in the backend to a frontend page. I have been looking at the providers but not really understanding it. If some one could link me to a tutorial that explains it better or give me some advice on how to do this, that would be awesome. Thanks

Hi, is your “Post’s Table” data saved in the database? or is it a static table created in the backend side?

I created the table in the database then used gii model generator and crud, so anything I add into the backend posts table saves to the posts database and vice versa

Then that shouldn’t be a problem. Just a small reminder that the frontend and backend folders are two different applications as what the documents stated. So basically, you need to fetch the data(on the database) that are saved from your backend to display on your frontend. If your model file(The one generated using gii) is saved on the common/models folder, then you can use it to display your table on your frontend.

I hope this makes sense.

Kind of made sense

so if I had a posts database which I can edit delete and save in the backend app and which I wanted to display the entries on the frontend app, to have all this in the common folder? Or just to copy the model file of the posts and place into the common file?

I’d suggest you just copy the model file of the posts to the common/model dir then extend the model to your frontend and backend models with specific functions.

Something like:




<?php


namespace frontend\models;


use common\models\Posts;


class FrontendPosts extends Posts

{

    public function showPosts()

    {


    }

}