How to get id of any page in codeigniter controller -
i new in codeigniter.
how id of below page in codeigniter controller.
www.abc.com/about-us - page
www.abc.com/blog/hello-world - blog details page
www.abc.com/city - categories
www.abc.com/search - pass input field
please me.
code model this
<?php defined('basepath') or exit('no direct script access allowed'); class blog_model extends my_model { public function __construct(){ parent::__construct(); } } ?>
and controller like
<?php defined('basepath') or exit('no direct script access allowed'); class blog extends my_controller { protected $per_page=1; public function __construct(){ parent::__construct(); $this->load->model('blog_model'); } public function index($page=1){ $page = $page-1; if($page<0){ $page =0; } $where = ' status = ?'; $where_data = array(1); $rs = $this->blog_model->__select('blogstablename','count(*) total_count', $where,$where_data); $record = $rs->result(); $total_row = $record[0]->total_count; $this->data['lists'] = $this->blog_model->__select('blogstablename','*',$where,$where_data,' blog_id desc',$page*$this->per_page,$this->per_page,3); $this->load->view('template/header.php'); $this->load->view('template/navbar.php',array('active_tab'=>'blog')); $this->load->view('blog',$this->data); $this->load->view('template/footer.php'); } } ?>
and in routes.php add line
$route['blog/(:any)'] = 'blog/index/$1';