public function indexAction($categoryCode = '') { $category = null; if ($categoryCode) { $category = Callbacks\Category::get($categoryCode, 'alias'); if (!$category) { $category = Callbacks\Category::get($categoryCode); } } if ($category) { $callbacks = $category->callbacks(['where' => [['view', 1]], 'order' => ['weight', 'asc']]); } else { $callbacks = Callbacks\Callback::getList(['where' => [['category_id', 0], ['view', 1]], 'order' => ['weight', 'asc']]); } $this->view->setTitle($category ? $category->name : 'Отзывы'); $this->view->page(['page' => $category ? $category->resolveTemplate() : 'current', 'content' => $category ? $category->resolveViewer() : 'index', 'data' => compact('category', 'callbacks')]); }
<div class = 'callbacks'> <h1>Отзывы</h1> <?php $callbacks = Callbacks\Callback::getList(['where' => ['view', '1'], 'order' => ['weight', 'asc']]); foreach ($callbacks as $callback) { echo "<h3>{$callback->name}<div class = 'time'>{$callback->date_create}</div></h3>"; echo "<p>" . nl2br($callback->text) . "</p>"; } ?> </div> <h3>Можете и вы в свободной форме оставить свой отзыв</h3> <?php $this->widget('Callbacks\\form');