Это класс который должен перехвачивать id и открывать информацию.
Код: Выделить всё
<?php
namespace app\models;
class MyList extends \yii\db\ActiveRecord{
public static function tableName()
{
return 'category';
}
public static function getAll()
{
$data = self::find()->all();
return $data;
}
public static function getOne($id)
{
$data = self::find()->where(['id'=>$id])->one();
return $data;
}
}
Код: Выделить всё
<?php
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\filters\VerbFilter;
use app\models\MyList;
class SiteController extends Controller
{
public function actionIndex()
{
return $this->render('index');
}
public function actionAbout()
{
return $this->render('about');
}
public function actionHello()
{
$var = 'Новинки сериалов:';
$array = MyList::getAll($id);
return $this->render('hello',['varInView'=>$var,'arrayInView'=>$array]);
}
public function actionView($id)
{
$one = MyList::getOne($id);
return $this->render('view',['one'=>$one]);
}
}