Advertisement
Guest User

Controller

a guest
Jul 9th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. <?php
  2. // defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Indeks extends CI_Controller {
  5.  
  6. // public function __construct() {
  7. // parent::__construct();
  8. // }
  9. /**
  10. * Index Page for this controller.
  11. *
  12. * Maps to the following URL
  13. * http://example.com/index.php/welcome
  14. * - or -
  15. * http://example.com/index.php/welcome/index
  16. * - or -
  17. * Since this controller is set as the default controller in
  18. * config/routes.php, it's displayed at http://example.com/
  19. *
  20. * So any other public methods not prefixed with an underscore will
  21. * map to /index.php/welcome/<method_name>
  22. * @see https://codeigniter.com/user_guide/general/urls.html
  23. */
  24. /*
  25. public function __construct() {
  26.  
  27. parent::__construct();
  28. $this->load->model('data', 'indeks');
  29. $this->load->library('session');
  30. $this->load->helper('date');
  31.  
  32. }
  33.  
  34. */
  35.  
  36. public function index($indeks=0) {
  37. if ($indeks<0) {
  38. redirect('indeks');
  39. }
  40. $this->load->model('data', 'indeks');
  41. $this->load->helper('analytics');
  42. $this->load->helper('weburi');
  43. $this->load->helper('content');
  44. $this->load->library('pagination');
  45. //$this->output->cache(10);
  46. $this->output->delete_cache();
  47.  
  48. $t['title'] = 'Kumpulan Berita Hari ini';
  49. $data['indeks'] = $t['title'] ;
  50.  
  51.  
  52. $t['indeks'] = $this->indeks->all_news($indeks);
  53. $raws_image = json_decode($t['indeks'][0]['image'],true) ;
  54.  
  55. $offset = 20;
  56. $pagging = (int) $this->uri->segment(3,0);
  57. $start = ((($pagging - 0) * $offset) < 0) ? 0 : (($pagging - 0) * $offset);
  58. #Pagination Start
  59. $total_data = count($t['indeks']);
  60. $t['end_page'] = ($total_data >= 20) ? TRUE : FALSE;
  61. $pagging = ($pagging > 0 ? $pagging : 0);
  62. $next = (int) $pagging + 20;
  63. $prev = (int) $pagging - 20;
  64.  
  65. $pagination = "";
  66. //prev button
  67. if ($pagging > 0)
  68. $pagination.= '<li><a href="'.base_url().'indeks/index/'.$prev.'" title="prev">Prev</a></li>';
  69.  
  70. //next button
  71. if ($t['end_page'])
  72. $pagination.= '<li><a href="'.base_url().'indeks/index/'.$next.'" title="next">Next</a></li>';
  73.  
  74. $t['pagging'] = $pagination;
  75.  
  76. #Menu
  77. $t['v_menu'] = $this->load->view('template/v_menu',NULL,TRUE);
  78. #Footer
  79. $t['v_footer'] = $this->load->view('template/v_footer',NULL,TRUE);
  80.  
  81. $this->load->view('pages/v_index' ,$t,FALSE);
  82.  
  83. }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement