public function projectAction() { $id = (int) $this->dispatcher->getParam('id', 'int'); $imagePos = (int) $this->request->getQuery('image', 'int', 1); $project = Project::findFirst(array("id = {$id} AND visible = '1'", array('cache' => array('key' => md5("Project::findById({$id})"), 'lifetime' => 60)))); if (!$project) { throw new Exception("Project ID = {$id} not found"); } $projectImage = ProjectImage::find(array("conditions" => "project_id = {$id}", "order" => "id ASC", "limit" => array("number" => 1, "offset" => $imagePos - 1))); $this->helper->title()->append($project->getTitle()); $this->helper->title()->append('Галерея проектов'); $this->view->imagePos = $imagePos; $this->view->project = $project; $this->view->projectImage = $projectImage[0]; }