public function parseRequest($manager, $request) { $pathInfo = $request->getPathInfo(); $pathInfo = chop($pathInfo, $manager->suffix); if (preg_match('%^([\\-\\w]+)?$%', $pathInfo, $matches) && $pathInfo != '') { $model = Page::findOne(['slug' => $matches[1]]); if ($model !== null) { $_GET['id'] = $model->id; return ["fluent/page/view", []]; } return false; } return false; }
public function actionView($id) { $page = Page::findOne($id)->getTranslation(Language::getCurrentLangID(), false); return $this->render('view', ['page' => $page]); }
/** * Finds the Page model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Page the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Page::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }