Advertisement
sinaga15

new controller

Nov 29th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4.  
  5.  
  6. class Read extends CI_Controller {
  7.  
  8. /**
  9. * Index Page for this controller.
  10. *
  11. * Maps to the following URL
  12. * http://example.com/index.php/welcome
  13. * - or -
  14. * http://example.com/index.php/welcome/index
  15. * - or -
  16. * Since this controller is set as the default controller in
  17. * config/routes.php, it's displayed at http://example.com/
  18. *
  19. * So any other public methods not prefixed with an underscore will
  20. * map to /index.php/welcome/<method_name>
  21. * @see https://codeigniter.com/user_guide/general/urls.html
  22. */
  23. public function __construct() {
  24. parent::__construct();
  25. $this->load->model('data', 'read');
  26. $this->load->library('session');
  27. $this->load->helper('form');
  28. $this->load->helper('url');
  29. $this->load->helper('html');
  30.  
  31. $this->load->library('form_validation');
  32. }
  33.  
  34. public function index()
  35. {
  36.  
  37.  
  38. #Construct
  39. $content_details = array();
  40. $t = array();
  41. $channel_main = $this->config->item("channel_main_id");
  42.  
  43. $t['title'] = 'News Portal Kids Now';
  44. $data['read'] = $t['title'] ;
  45. $t['read'] = $this->read->all();
  46.  
  47.  
  48.  
  49. $a['v_detail'] = $this->load->view('read/v_detail', $t, true);
  50. //$t['select_data'] = $this->read->get();
  51.  
  52.  
  53.  
  54. //$t['breaking'] = $this->tommy->all();
  55. //var_dump($t['isi'] );
  56.  
  57. //$this->benchmark->mark('end_view');
  58. $this->load->view("read/v_detail", $t);
  59. //$page = $this->load->view("read/v_detail", $t);
  60. // return $page;
  61.  
  62. //$result = $this->tommy->proses_tampil($id);
  63. //return $pages;
  64. }
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. public function detail($slug) {
  72. $this->load->model('data', 'detail');
  73. $this->load->library('form_validation');
  74. //$t['judul'] = $judul->judul . ' | News Portal';
  75. //$this->db->get_where($this->read, array('judul' => $judul[1]));
  76. //$t['title'] = $post->title . ' | News Portal';
  77.  
  78. //$t['title'] = $this->detail->all();
  79. //$data['detail'] = $t['title'] ;
  80.  
  81. $t['read'] = $this->detail->all(10);
  82. //$t['detail'] = $this->detail->anjing($idartikel);
  83. $t['populer'] = $this->detail->populer();
  84. $t['category'] = $this->detail->kategori();
  85. $t['opini'] = $this->detail->all_opini(1);
  86. //$t['read'] = $this->detail->populer(3);
  87. //$t['category'] = $this->detail->kategori($idartikel);
  88. //$t['nasional'] = $this->detail->all_nasional();
  89. //$t['ekonomi'] = $this->detail->all_ekonomi();
  90. //$t['internasional'] = $this->detail->all_internasional();
  91. //$t['olahraga'] = $this->detail->all_olahraga();
  92. //$t['humaniora'] = $this->detail->all_humaniora();
  93. //$t['muda'] = $this->detail->all_muda();
  94. //$t['video'] = $this->detail->videos();
  95. //$id = $this->uri->segment(3);
  96. //$t['berita'] = $this->data->get_detail($id);
  97. //$t['tags'] = $this->read->all_hastag();
  98. $t['detail'] = $this->detail->get($slug);
  99. $t['title'] = $t['detail'][0]['title'];
  100. $t['title'] = $t['detail'][0]['title'];
  101. //$t['title'] = (isset($t['detail'][0]['title']) && $t['detail'][0]['title'] = "");
  102. //$t['image'] = (isset($t['detail'][0]['image']) && $t['detail'][0]['image'] = "");
  103.  
  104.  
  105. //echo '<pre>';
  106.  
  107. $data = json_decode($t['detail'][0]['image'],true) ;
  108. print_r($data);
  109.  
  110. $t['image'] = $data['file'];
  111.  
  112.  
  113. //$raw_image = json_decode(json_decode($t['detail'][0]['image'],true),TRUE);
  114. //$t['image'] = $raw_image['file'];
  115.  
  116. //$data = json_decode(json_decode($t['detail'][0]['image'],true),TRUE);
  117. //$t['image'] = $data['file'];
  118. echo "<pre>";
  119. print_r($t['image']);
  120. echo "</pre>";
  121. if(!$t['detail']) {
  122. $this->load->view(
  123. 'Could not load the requested item',
  124. 'warning'
  125. );
  126. redirect('read');
  127. return;
  128. }
  129. //$t['read'] = $this->read->select_data();
  130.  
  131. //$t['title'] = $t->title . ' | MI';
  132. // $t['data'] = $t;
  133. //$t['penulis'] = penulis($t['penulis']->nip);
  134.  
  135. $this->load->view("read/v_detail", $t);
  136.  
  137. }
  138.  
  139.  
  140.  
  141.  
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement