public function actionIndex() { return $this->render(['items' => Praktice::query()->all()]); }
public function actionPraktice_item($year, $month, $day, $id) { $date = $year . $month . $day; $newsItem = Praktice::find(['date' => $date, 'id_string' => $id]); if (is_null($newsItem)) { throw new Exception('Нет такой прктики'); } $newsItem->incViewCounter(); $row = $newsItem->getFields(); return $this->render(['item' => $newsItem->getFields(), 'lastList' => Praktice::queryList()->where(['not in', 'id', $row['id']])->orderBy(['date_insert' => SORT_DESC])->limit(3)->all()]); }
/** * @param array $row gs_praktice * * @return string */ public static function prakticeItem($row) { if (!is_array($row)) { $id = $row; $item = \app\models\Praktice::find($id); if (is_null($item)) { return ''; } $row = $item->getFields(); } // Заголовок $html[] = Html::tag('div', Html::tag('h4', $row['header']), ['class' => 'header']); // картинка с ссылкой $html[] = Html::tag('p', Html::a(Html::img($row['image'], ['width' => '100%', 'class' => 'thumbnail']), self::getPrakticeUrl($row))); // Описание $html[] = Html::tag('p', $row['description']); return Html::tag('div', join('', $html), ['class' => 'col-lg-4 prakticeItem']); }