function paginationAction($id)
 {
     $totalpage = "";
     //tinh xem minh co khoan bao nhieu page
     $per_page = 3;
     //tong so item tren mot trang
     $record = count(News::getAll());
     //tong so hang cua csdl
     if ($record > $per_page) {
         $totalpage = ceil($record / $per_page);
     } else {
         $totalpage = 1;
     }
     $start = ($id - 1) * $per_page;
     //tinh so dong bat dau trong co so du lieu tu page nhap vao
     $end_page = $totalpage - 1;
     $html = "<div class='pagi'><ul>";
     for ($i = 1; $i <= $totalpage; $i++) {
         if ($id == $i) {
             $html .= "<li class='current'><a href='/page/{$i}'> {$i} </a></li>";
         } else {
             $html .= "<li ><a href='/page/{$i}'> {$i} </a></li>";
         }
     }
     $html .= '</ul></div>';
     $data['news'] = News::getPaginate($start, $per_page);
     $data['html'] = $html;
     $data['tag'] = News::getAllTag();
     return $this->render('news/mainpage.html.twig', $data);
 }
 public function viewAction()
 {
     $data = array();
     $data['news'] = News::getAll();
     return $this->render('admin/viewnews.html.twig', $data);
 }