public function author($req, $res, $args) { // Get number of pages $nbThemes = ThemeModel::countGetAuthor($args['author']); $nbPages = ceil(($nbThemes + 1) / 20); // Determine the offset $p = !isset($args['page']) || $args['page'] <= 1 || $args['page'] > $nbPages ? 1 : intval($args['page']); $offset = 20 * ($p - 1); // Generate paging links $pagination = Router::paginate($nbPages, $p, 'themes/author/' . $args['author'] . '/#'); $themes = ThemeModel::getAuthor($args['author']); return View::setPageInfo(['themes' => $themes, 'pagination' => $pagination, 'title' => 'Author', 'active_nav' => 'themes', 'top_right_link' => ['url' => Router::pathFor('themes.create'), 'text' => 'Add theme']])->addBreadcrumb([Router::pathFor('themes') => 'Themes', 'Authored by ' . htmlspecialchars($args['author'])])->addTemplate('themes/index.php')->display(); }