Yii2 pass category id to action

I am wanting to display posts by category, where by the URL would be something along the lines of

localhost:8888/advanced/article/category?id=2

Similar to how a single post/article is displayed in the improved advanced template (localhost:8888/advanced/article/view?id=33)

I have the following code which I need to pass the category_id at the minute if I go to localhost:8888/advanced/article/category?id=1 i get redirected to login.




  public function actionCategory($id)

    {


        $model = new Article();


        $searchModel = new ArticleSearch();


        $query = Article::find()

        ->where(['category' => $id]);


         $dataProvider = new ActiveDataProvider([

                        'query' => $query,

                        ]);


        return $this->render('category', [

            'searchModel' => $searchModel,

            'dataProvider' => $dataProvider,

            'model'=>$model,

        ]);

    }



Database

-id

-user_id

-avatar

-filename

-title

-summary

-content

-status

-category_id

Query should filter category_id field, and not category.




$query = Article::find()

->where(['category_id' => $id]);



I thought passing the id in the url for example would then be used as the value to look for in the query so for example if I typed in:

Currently I just get a 404 error page, and if i use a lower case c in the URL it redirects to login.

localhost:8888/article/Cateogry?id=2 then it would be like doing the following




$query = Article::find()

->where(['category_id' => 2]);



Are you sure that you haven’t an accessFilter that filter your request?

http://www.yiiframework.com/doc-2.0/guide-security-authorization.html

Thank you for your assistance :) , I totally forgot about rbac ups :(