Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ini modelsnya
- public function get($slug) {
- //$sinaga = array();
- $this->db->select('micom_news.*, micom_compartments.id, micom_compartments.title as nama');
- $this->db->from('micom_news');
- $this->db->join('micom_compartments', 'micom_compartments.id = micom_news.compartment','left');
- //$this->db->order_by('hits');
- $this->db->limit(5);
- $sql = $this->db->get_where($this->read, array('micom_news.slug' =>isset($slug) ? $slug : ""));
- $t = $sql->result_array();
- //return $t[0];
- return $t;
- //echo "<pre>";
- //print_r($t);
- //echo "</pre>";
- //$t = $this->db->get($sql)->row_array();
- //return $this->db->get();
- }
- ----------------------------------------------------------------------------------------------------------------------------------
- ini controller read detail
- public function detail($slug) {
- $this->load->model('data', 'detail');
- $this->load->library('form_validation');
- $t['read'] = $this->detail->all(10);
- //$t['detail'] = $this->detail->anjing($idartikel);
- $t['populer'] = $this->detail->populer();
- $t['kategori'] = $this->detail->kategori();
- $t['opini'] = $this->detail->all_opini(1);
- $t['detail'] = $this->detail->get($slug);
- //$t['title'] = $t['detail'][0]['title'];
- $t['title'] = $t['detail'][0]['title'];
- $t['category'] = $t['detail'][0]['title'];
- //echo "<pre>";
- //print_r($t['kategori']);
- //echo "</pre>";
- //$t['title'] = (isset($t['detail'][0]['title']) && $t['detail'][0]['title'] = "");
- //$t['image'] = (isset($t['detail'][0]['image']) && $t['detail'][0]['image'] = "");
- //echo '<pre>';
- //$data = json_decode($t['detail'][0]['image'],true) ;
- //print_r($data);
- //$t['image'] = $data['file'];
- //$file = json_decode($t['detail'][0]['image']);
- //$t['image'] = $file->file;
- if(isset($t['detail'][0]['image'])){
- $raw_image = json_decode($t['detail'][0]['image'],true);
- $t['detail'][0]['image'] = $raw_image['file'];
- //var_dump($t['detail'][0]['image']);
- }
- if(!$t['detail']) {
- //================error lagi deh============
- /*
- $this->load->view(
- 'Could not load the requested item',
- 'warning'
- );
- */
- redirect('read');
- }
- $this->load->view("read/v_detail", $t);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement