How take get parameters for sorting items by category?

In my database I have items with categry field (from 1… to inf)

Controller action:

public function actionIndex()


        $searchModel = new AdsSearch();

        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

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

            'searchModel' => $searchModel,

            'dataProvider' => $dataProvider,




<?= ListView::widget([

    'dataProvider' => $dataProvider,

    'itemOptions' => ['class' => 'item'],

    'itemView' => '_item_view',,

]) ?>

I have enabled prettyUrl

'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,


And .htaccess in frontend/web/

RewriteEngine on


RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

  1. How can I show items that were find only by category?

Now show all items with mixed categories

I want to make or with category = 1

  1. Is there any article how to make instead number? I store category names in $app->params

Next item page with id=5 will be