Esempio n. 1
0
 /**
  * List all profiles in website with pagination
  * @return string
  * @throws \Ffcms\Core\Exception\NativeException
  * @throws \Ffcms\Core\Exception\SyntaxException
  */
 public function actionIndex()
 {
     // init Active Record
     $query = new ProfileRecords();
     // set current page and offset
     $page = (int) $this->request->query->get('page');
     $offset = $page * self::ITEM_PER_PAGE;
     // build pagination
     $pagination = new SimplePagination(['url' => ['profile/index'], 'page' => $page, 'step' => self::ITEM_PER_PAGE, 'total' => $query->count()]);
     // build listing objects
     $records = $query->orderBy('id', 'desc')->skip($offset)->take(self::ITEM_PER_PAGE)->get();
     // display viewer
     return $this->view->render('index', ['records' => $records, 'pagination' => $pagination]);
 }