Assalamualaikum Warahmatullahi Wabarakatuh... Alhamdulillah karena mulai banyak yang menyakan hal ini akhirnya saya buat topic khusus saja. "Cara Persingkat URL Swarakalibata Ci Seperti Pada CMS Wordpress' sudah pernah dibahas juga disini,.. https://members.phpmu.com/forum/read/bisakah-link-artikel-pada-swarakalibata-ci-di-rubah Berikut tahapannya, pertama buka file "application/config/routes.php" Cari baris : $route['default_controller'] = 'main'; ubah menjadi : <?php 'default_controller' => 'main', 'main' => 'main', 'administrator' => 'Administrator', 'agenda' => 'agenda', 'albums' => 'albums', 'berita' => 'berita', 'download' => 'download', 'halaman' => 'halaman', 'hubungi' => 'hubungi', 'kategori' => 'kategori', 'konsultasi' => 'konsultasi', 'kontributor' => 'kontributor', 'playlist' => 'playlist', 'polling' => 'polling', 'tag' => 'tag', ); $route['(:any)'] = 'news/$1/$2'; ?> Selanjutnya buat Controller baru dengan nama News.php dan isikan script berikut : <?php defined('BASEPATH') OR exit('No direct script access allowed'); class News extends CI_Controller { private $page = null; private $params = null; public function __construct (){ parent::__construct(); $this->page = $this->uri->segment(1); $this->reroute(); } public function _remap ($page, $params = array() ){ $this->params = $params; } } if($this->params){ }else{ $this->index(); } }else{ $this->index(); } } function index($id){ $query = $this->model_utama->view_join_two('berita','users','kategori','username','id_kategori',array('judul_seo' => $this->uri->segment(1)),'id_berita','DESC',0,1); if ($query->num_rows()<=0){ redirect('main'); }else{ $row = $query->row_array(); $data['title'] = cetak($row['judul']); $data['description'] = cetak_meta($row['isi_berita'],0,500); $data['keywords'] = cetak($row['tag']); $data['rows'] = $row; $dataa = array('dibaca'=>$row['dibaca']+1); $where = array('id_berita' => $row['id_berita']); $this->model_utama->update('berita', $dataa, $where); $this->load->helper('captcha'); 'img_path' => './captcha/', 'img_url' => base_url().'captcha/', 'font_path' => './asset/Tahoma.ttf', 'font_size' => 17, 'img_width' => '150', 'img_height' => 33, 'border' => 0, 'word_length' => 5, 'expiration' => 7200 ); $cap = create_captcha($vals); $data['image'] = $cap['image']; $this->session->set_userdata('mycaptcha', $cap['word']); $this->template->load(template().'/template',template().'/detailberita',$data); } } private function reroute (){ if($this->page == $this->router->class){ if($this->uri->total_segments() > 1){ $this->load->helper('url'); $uri = substr($this->uri->uri_string, strlen($this->page)+1); redirect($uri); }else{ $this->noroute($this->page); } } } } ?> Selesai dan simpan,.. URL sebelumnya : http://domain.com/berita/detail/usai-bertempur-banyak-tentara-israel-hilang-di-jalur-gaza sekarang coba akses berita dengan url : http://domain.com/usai-bertempur-banyak-tentara-israel-hilang-di-jalur-gaza Bagaimaan cukup keren bukan? :D insyaallah swarakalibata ci versi berikutnya akan kita ubah default url berita jadi begini juga,.. yang mau duluan silahkan ikuti tahapan di atas, semoga bermanfaat...
|