Guest User

Untitled

a guest
Oct 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <?php
  2.  
  3. class Galleries extends MY_Controller {
  4.  
  5. public function __construct() {
  6. parent::__construct();
  7. }
  8.  
  9. public function index() {
  10. $gallery = new Gallery;
  11. $total_rows = $gallery->count();
  12. $per_page = setting('galleries.per_page', FALSE, 10);
  13. $this->load->library('pagination');
  14. $this->pagination->initialize(array(
  15. 'total_rows' => $total_rows,
  16. 'per_page' => $per_page,
  17. 'uri_segment' => 'page',
  18. 'base_url' => galleries_url('')
  19. ));
  20. $galleries = $gallery->limit($per_page)->offset((int) param('page'))->get();
  21. $this->load->view('galleries/index', array(
  22. 'galleries' => $galleries,
  23. 'pagination' => $this->pagination->create_links()
  24. ));
  25. }
  26.  
  27. public function show() {
  28. $id = param('id');
  29. if(! $id) {
  30. show_404();
  31. }
  32. $gallery = new Gallery($id);
  33. if(! $gallery->exists()) {
  34. show_404();
  35. }
  36. $this->load->view('galleries/show', array(
  37. 'gallery' => $gallery,
  38. 'comments' => $comments,
  39. 'pagination' => $this->pagination->create_links()
  40. ));
  41.  
  42.  
  43. $comment = new Comment();
  44. $total_rows = $comment->where('resource_id', $gallery->id)->count();
  45. $offset = (int) param('page');
  46. $per_page = setting('comments.posts_per_page', FALSE, 20);
  47. $this->load->library('pagination');
  48. $this->pagination->initialize(array(
  49. 'base_url' => shop_item_url(param('brand'), param('category'), $id, param('name'), ''),
  50. 'per_page' => $per_page,
  51. 'uri_segment' => 'page',
  52. 'total_rows' => $total_rows
  53. ));
  54. $comment->limit($per_page)->offset($offset)->order_by('created_at', 'asc');
  55. $comments = $comment->get();
  56.  
  57.  
  58. }
  59.  
  60. }
Add Comment
Please, Sign In to add comment