function product_index() { $data = array(); $data['template_file'] = 'product/product.php'; $data['title'] = 'Sản Phẩm'; if (isset($_GET['id'])) { $id = $_GET['id']; $subquery = '(SELECT id FROM catalog WHERE parent_id=' . $id . ')'; $page = isset($_GET['page']) ? $_GET['page'] : 1; $config = array('current_page' => $page, 'total_record' => count(model('product')->get_product('WHERE catalog_id=' . $id . ' OR catalog_id in ' . $subquery . ' ORDER BY created DESC')), 'limit' => 9, 'link_full' => 'index.php?c=product&id=' . $id . '&page={page}', 'link_first' => 'index.php?c=product&id=' . $id); $paging = new Pagination(); $paging->init($config); $data['page'] = $paging->html(); $data['data'] = model('product')->paginate($page, 9, 'WHERE catalog_id=' . $id . ' OR catalog_id in ' . $subquery . ' ORDER BY created DESC'); $catalog = model('catalog')->catalog('WHERE id=' . $id); $data['catalog'] = $catalog; $data['title'] = $catalog[0]['name']; } else { $page = isset($_GET['page']) ? $_GET['page'] : 1; $config = array('current_page' => $page, 'total_record' => count(model('product')->get_product()), 'limit' => 9, 'link_full' => 'index.php?c=product&page={page}', 'link_first' => 'index.php?c=product'); $paging = new Pagination(); $paging->init($config); $data['page'] = $paging->html(); $data['data'] = model('product')->paginate($page, 9, 'ORDER BY created DESC'); } render('layout_home.php', $data); }
function blog_index() { $data = array(); $data['template_file'] = 'blog/blog.php'; $data['title'] = 'Bài Viết'; $page = isset($_GET['page']) ? $_GET['page'] : 1; $config = array('current_page' => $page, 'total_record' => count(model('news')->all()), 'limit' => 10, 'link_full' => 'index.php?c=blog&page={page}', 'link_first' => 'index.php?c=blog'); $paging = new Pagination(); $paging->init($config); $data['page'] = $paging->html(); $data['data'] = model('news')->paginate($page, 10, 'ORDER BY created DESC'); $data['news_most'] = model('news')->news_index('view', 4); render('layout_home.php', $data); }