public function viewAction($id) { $data = $this->setData(); $data['post'] = Post::getPostById($id); $data['IMG_DIR'] = $this->IMG_POST_DIR; $data['others'] = Post::getOtherPost2($data['post']['cateID'], $id); foreach ($data['others'] as $p) { $p['link'] = strtolower($this->convertUnicode($p['title'])); } if ($data['post'] == NULL) { return $this->redirect('home'); } else { $data['title'] = $data['post']['title']; return $this->render('post/view.html.twig', $data); } }