Codeigniter Perpage Link Not Showing First In URL Pagination links - codeigniter

I am making my table head links sortable and orderable how ever my per_page does not show up first
http://localhost/project-1/forum/category/1/&order=asc?per_page=1
It should show like
http://localhost/codeigniter/forum/category/1/?per_page=1&order=asc
Question when I click on the pagination links if the have been order or sorted how can I make sure that when I click on a pagination link even though has been order/sorted will still allways show ?per_page first in url.
$url = '';
if ($this->input->get('sort')) {
$url .= '&sort=' . $this->input->get('sort');
}
if ($this->input->get('order')) {
$url .= '&order=' . $this->input->get('order');
}
$config["base_url"] = base_url('forum/category') .'/'. $category_id .'/'. $url;
Controller
<?php
class Forum extends MX_Controller {
public function __construct() {
parent::__construct();
$this->load->model('catalog/forum/forum_model');
$this->load->library('pagination');
}
public function category() {
$this->document->set_title('Forums');
$category_id = $this->uri->segment(3);
if ($this->input->get('sort')) {
$sort = $this->input->get('sort');
} else {
$sort = 'message';
}
if ($this->input->get('order')) {
$order = $this->input->get('order');
} else {
$order = 'asc';
}
$url = '';
if ($this->input->get('per_page')) {
$url .= '?per_page=' . $this->input->get('per_page');
}
if ($this->input->get('sort')) {
$url .= '&sort=' . $this->input->get('sort');
}
if ($this->input->get('order')) {
$url .= '&order=' . $this->input->get('order');
}
$config["base_url"] = base_url('forum/category') .'/'. $category_id .'/'. $url;
$config["total_rows"] = $this->forum_model->total_category($category_id);
$config["per_page"] = 1;
$config['page_query_string'] = TRUE;
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$start = ($this->input->get('per_page')) ? $this->input->get('per_page') : '';
$filter_data = array(
'limit' => $config["per_page"],
'start' => $start,
'category_id' => $category_id,
'sort' => $sort,
'order' => $this->input->get('order')
);
$data['threads'] = array();
$results = $this->forum_model->get_threads_for_forum($filter_data);
foreach ($results as $result) {
$data['threads'][] = array(
'thread_id' => $result['thread_id'],
'user_id' => $result['user_id'],
'username' => $result['username'],
'subject' => $result['subject'],
'link' => site_url('thread') . '-' . $result['thread_id'],
'total' => $this->forum_model->total_threads($result['thread_id']),
'date_created' => date('d-m-Y', strtotime($result['date_created'])),
'user_link' => site_url('user') . '-' . $result['user_id']
);
}
$data['header'] = Modules::run('catalog/common/header/index');
$data['footer'] = Modules::run('catalog/common/footer/index');
$data['menu'] = Modules::run('catalog/common/menu/index');
$data['pagination'] = $this->pagination->create_links();
$data['back'] = site_url('forum');
$data['thread'] = site_url('newthread') . '?fid=' . $category_id;
$url = '';
if ($order == 'asc') {
$url .= '?order=desc';
} else {
$url .= '?order=asc';
}
$data['message'] = site_url('forum/category') .'/'. $category_id .'/'. $url;
$data['sort'] = $sort;
$data['order'] = '';
$this->load->view('default/template/forum/forum_thread_view', $data);
}
}

Set your default category id if url does not contain:
if ($this->uri->segment(3) == 'null') {
$category_id = 1; //set default for null
} else {
$category_id = $this->uri->segment(3);
}
Edit your config['base_url'] and add set $config['suffix'] if $_GET is not
empty.
New Pagination config:
$config["base_url"] = base_url('forum/category'); //no need custom category id
if (count($_GET) > 0)
$config['suffix']='?'.http_build_query($_GET,'',"&");//to encode requested data
$config["per_page"] = 1;
$config['page_query_string'] = TRUE;
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";

I don't see any:
$config[‘reuse_query_string’] = TRUE;
This will allow to use mixed type of urls. This was not possible before CI 3.0.

Related

pagination doesn't work in codeigniter

I made an optional search that makes the user search with username or customer or date from/to the result returning well to the first page but if I click on another page the result return nothing
this my front and all that input optional
i think the problem the pagination path because if i fill all inputs the pagination path become
controllername/userid/customerid/fromdate/todate
and if skip any input I find the pagination path is missing that
this my controller
public function search($page_num = 1){
$this->load->library('pagination');
$this->load->helper("url");
$this->load->model(array('CustomReport_m','user','Customer_m')); // This array to save number of lines only
$username=$this->input->post('select_user');
$username = ($this->uri->segment(3)) ? $this->uri->segment(3) : $username;
$customer=$this->input->post('select_customer');
$customer = ($this->uri->segment(4)) ? $this->uri->segment(4) : $customer;
$datefrom=$this->input->post('from');
$datefrom = ($this->uri->segment(5)) ? $this->uri->segment(5) : $datefrom;
$dateend=$this->input->post('to');
$dateend = ($this->uri->segment(6)) ? $this->uri->segment(6) : $dateend;
$total_row = $this->CustomReport_m->search_count($username,$customer,$datefrom,$dateend);
//$config['use_page_numbers'] = TRUE;
$config['base_url'] = site_url("CustomReport/search/$username/$customer/$datefrom/$dateend");
$config['total_rows'] = $total_row;
$config['per_page'] = 10;
$choice = $config["total_rows"]/$config["per_page"];
$config["num_links"] = floor($choice);
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = '&laquo';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '&raquo';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
if ($this->uri->segment(7)) {
$page = ($this->uri->segment(7));
} else {
$page = 1;
}
$str_links = $this->pagination->create_links();
$data["links"]= explode(' ', $str_links);
$data['users']=$this->user->display_users();
$data['userdata'] = $this->user->userdata();
$data['customers']= $this->Customer_m->index();
// if(isset($_POST['submit'])){
$data["rsl"] =$this->CustomReport_m->search($username,$customer,$datefrom,$dateend,$config["per_page"],$page);
$this->load->view('customreport_v',$data);
// }else{
// redirect('CustomReport','refresh');
// }
}
This is my model
public function search_count($username,$customer,$datefrom,$dateend) {
$this->db->select('*');
$this->db->from('transactions');
if (!empty($customer)){
$this->db->where('t_customer_id',$customer);
}
if (!empty($username)){
$this->db->where('t_u_id',$username);
}
if (!empty($dateend)){
$this->db->where('t_date <=',$dateend);
}
if (!empty($datefrom)){
$this->db->where('t_date >=',$datefrom);
}
return $this->db->get()->num_rows();
}
public function search($username,$customer,$datefrom,$dateend,$limit,$start)
{
$start=$start-1;
$this->db->select('*');
$this->db->from('transactions');
if (!empty($customer)){
$this->db->where('t_customer_id',$customer);
}
if (!empty($username)){
$this->db->where('t_u_id',$username);
}
if (!empty($dateend)){
$this->db->where('t_date <=',$dateend);
}
if (!empty($datefrom)){
$this->db->where('t_date >=',$datefrom);
}
$this->db->limit($limit,$start);
$query=$this->db->get();
if($query->num_rows() > 0){
return $query->result();
}else{
return $query->result();
}
}
this my route
$route['CustomReport/(:num)']="CustomReport/index/$1";

Search not working and fetch wrong results in Codeigniter

the Search doesn't work and retrieves wrong results
That worked with me if I searched with username only but when I made that search with username, customer and dates the results not become incorrectly
My Model
public function search_count($username,$customer,$datefrom,$dateend) {
$this->db->where('t_u_id',$username);
$this->db->where('t_customer_id',$customer);
$this->db->where('t_date <=',$dateend);
$this->db->where('t_date >=',$datefrom);
return $this->db->count_all("transactions");
}
public function search($username,$customer,$datefrom,$dateend,$limit,$start)
{
$start=$start-1;
$this->db->select('*');
$this->db->from('transactions');
$this->db->where('t_u_id',$username);
$this->db->where('t_customer_id',$customer);
$this->db->where('t_date <=',$dateend);
$this->db->where('t_date >=',$datefrom);
$this->db->limit($limit,$start);
$query=$this->db->get();
if($query->num_rows() > 0){
return $query->result();
}else{
return $query->result();
}
}
My Controller
public function search($page_num = 1){
$this->load->library('pagination');
$this->load->helper("url");
$this->load->model(array('CustomReport_m','user','Customer_m')); // This array to save number of lines only
$username=$this->input->post('select_user');
$username = ($this->uri->segment(3)) ? $this->uri->segment(3) : $username;
$customer=$this->input->post('select_customer');
$customer = ($this->uri->segment(4)) ? $this->uri->segment(4) : $customer;
$datefrom=$this->input->post('from');
$datefrom = ($this->uri->segment(5)) ? $this->uri->segment(5) : $datefrom;
$dateend=$this->input->post('to');
$dateend = ($this->uri->segment(6)) ? $this->uri->segment(6) : $dateend;
$total_row = $this->CustomReport_m->search_count($username,$customer,$datefrom,$dateend);
//$config['use_page_numbers'] = TRUE;
$config['base_url'] = site_url("CustomReport/search/$username/$customer/$datefrom/$dateend");
$config['total_rows'] = $total_row;
$config['per_page'] = 10;
$choice = $config["total_rows"]/$config["per_page"];
$config["num_links"] = floor($choice);
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = '&laquo';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '&raquo';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
if ($this->uri->segment(7)) {
$page = ($this->uri->segment(7));
} else {
$page = 1;
}
$str_links = $this->pagination->create_links();
$data["links"]= explode(' ', $str_links);
$data['users']=$this->user->display_users();
$data['userdata'] = $this->user->userdata();
$data['customers']= $this->Customer_m->index();
if(isset($username)and !empty($username)){
$data["rsl"] =$this->CustomReport_m->search($username,$customer,$datefrom,$dateend,$config["per_page"],$page);
$this->load->view('customreport_v',$data);
}else{
redirect('CustomReport','refresh');
}
}
I think you should use this:
public function search_count($username,$customer,$datefrom,$dateend) {
$this->db->select('*');
$this->db->from('transactions');
$this->db->where('t_u_id', $username);
$this->db->where('t_customer_id', $customer);
$this->db->where('t_date <=', $dateend);
$this->db->where('t_date >=', $datefrom);
return $this->db->get()->num_rows();
}
Because count_all function just returns total of rows, it cannot apply where.

Custom Pagination Page Count Message

On my controller I am trying to be able to display a message where it counts from 1 "Your On Page 1" etc
How ever it does not start of at 1 it starts at 0 "Your On Page 0"
$message = '';
$message .= '<p>' . sprintf('Your on page %d', ($config['total_rows']) ? (($start - 1) * $config['per_page']) + 1 : 0) . '</p>';
$message .= '<p>Total ( Pages ' . ceil($config['total_rows'] / $config['per_page']) . ' )</p>';
$data['total'] = $message;
Question: How can I make sure that it can count from 1 instead of 0 in message with out effecting the main pagination on controller
Controller
<?php
class Forum extends MX_Controller {
public function __construct() {
parent::__construct();
$this->load->model('catalog/forum/forum_model');
$this->load->library('pagination');
}
public function category() {
$this->document->set_title('Forums');
$category_id = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
if ($this->input->get('order')) {
$order = $this->input->get('order');
} else {
$order = 'asc';
}
if ($this->input->get('sort')) {
$sort = $this->input->get('sort');
} else {
$sort = 'message';
}
$url = '';
if ($this->input->get('sort')) {
$url .= '?sort=' . $this->input->get('sort');
}
if ($this->input->get('order')) {
$url .= '&order=' . $this->input->get('order');
}
$config["base_url"] = base_url('forum/category') .'/'. $category_id .'/';
$config["total_rows"] = $this->forum_model->total_category($category_id);
$config["per_page"] = 1;
$config['page_query_string'] = TRUE;
$config['reuse_query_string'] = TRUE;
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$start = ($this->input->get('per_page')) ? $this->input->get('per_page') : '';
$filter_data = array(
'limit' => $config["per_page"],
'start' => $start,
'category_id' => $category_id,
'sort' => ($this->input->get('sort')) ? $this->input->get('sort') : 'message',
'order' => ($this->input->get('order')) ? $this->input->get('order') : 'asc'
);
$data['threads'] = array();
$results = $this->forum_model->get_threads_for_forum($filter_data);
foreach ($results as $result) {
$data['threads'][] = array(
'thread_id' => $result['thread_id'],
'user_id' => $result['user_id'],
'username' => $result['username'],
'subject' => $result['subject'],
'link' => site_url('thread') . '-' . $result['thread_id'],
'total' => $this->forum_model->total_threads($result['thread_id']),
'date_created' => date('d-m-Y', strtotime($result['date_created'])),
'user_link' => site_url('user') . '-' . $result['user_id']
);
}
$data['back'] = site_url('forum');
$data['newthread'] = site_url('newthread') . '?fid=' . $category_id;
$url = '';
if ($order == 'asc') {
$url .= '&order=desc';
} else {
$url .= '&order=asc';
}
if ($this->input->get('per_page')) {
$url .= '&per_page=' . $this->input->get('per_page');
}
$data['thread_message'] = site_url('forum/category') .'/'. $category_id .'/'. '?sort=message' . $url;
$data['date_created'] = site_url('forum/category') .'/'. $category_id .'/'. '?sort=date_created' . $url;
$data['sort'] = $sort;
$data['order'] = $order;
$total_threads = $this->forum_model->get_total_threads_for_category($category_id);
$message = '';
$message .= '<p>' . sprintf('Your on page %d', ($config['total_rows']) ? (($start - 1) * $config['per_page']) + 1 : 0) . '</p>';
$message .= '<p>Total ( Pages ' . ceil($config['total_rows'] / $config['per_page']) . ' )</p>';
$data['total'] = $message;
$data['header'] = Modules::run('catalog/common/header/index');
$data['footer'] = Modules::run('catalog/common/footer/index');
$data['menu'] = Modules::run('catalog/common/menu/index');
$this->load->view('default/template/forum/forum_thread_view', $data);
}
}
It ended up being a simple fix had brain fart should of picked it up straight away.
I changed
(($start - 1) * $config['per_page']) + 1 : 0)
To
(($start - 0) * $config['per_page']) + 1 : 0)

Codeigniter Pagination 3.0.4 Sort Directories And Files

I have a working file manager with codeIgniter 3.0.4 pagination library.
I am trying to make sure it displays the directory's first and then files in the pagination.
Currently the codeigniter pagination sorts the directories and files all by name.
Question with codeigniter pagination how can I make sure it all ways displays the directories first. Then sorts out the files.
<?php
class Filemanager extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->library('upload');
$this->load->helper('text');
$this->load->library('pagination');
}
public function index($results = NULL) {
$data['title'] = 'File Manager';
$this_input_get_directory = $this->input->get('directory');
if (isset($this_input_get_directory)) {
$directory = scandir(FCPATH . 'images/catalog/' . $this_input_get_directory . '/', 1);
} else {
$directory = scandir(FCPATH . 'images/catalog/', 1);
}
$files = array_diff($directory, array('.', '..'));
$files_limit = 3;
$input_get_per_page = $this->uri->segment(2);
$input_get_per_page += $files_limit;
$config['base_url'] = base_url('filemanager');
$config['total_rows'] = count($files);
$config['per_page'] = $files_limit;
$config['uri_segment'] = 2;
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$data['images'] = array();
foreach ($files as $file => $value) {
$url = '';
if (isset($this_input_get_directory)) {
$url .= $this_input_get_directory . '/';
} else {
$url .= '';
}
if ($file < $input_get_per_page && $file >= $input_get_per_page - $files_limit) {
if (is_dir(FCPATH . 'images/catalog/' . $value)) {
$data['images'][] = array(
'thumb' => '',
'type' => 'directory',
'href' => site_url('filemanager') . '?directory='. $url . $value,
'name' => $value
);
} elseif (is_file(FCPATH . 'images/catalog/' . $url . $value)) {
$data['images'][] = array(
'thumb' => $this->resize($value, 100, 100),
'type' => 'image',
'name' => $value
);
}
}
}
$this->load->view('template/common/filemanager_view', $data);
}
}
Solved I have found some code from some where else that made it work for me. I have also used now array_reverse(); all working so far.
<?php
class Filemanager extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->library('upload');
$this->load->helper('text');
$this->load->library('pagination');
$this->load->helper('custom');
define('DIR_IMAGE', FCPATH . 'images/');
}
public function index() {
$data['title'] = 'File Manager';
if ($this->uri->segment(3)) {
$this_input_get_directory = $this->uri->segment(2) . '/' . $this->uri->segment(3);
} else {
$this_input_get_directory = $this->uri->segment(2) . '/' . $this->uri->segment(3);
}
if (isset($this_input_get_directory)) {
$directory = rtrim(DIR_IMAGE . 'catalog/' . str_replace(array('../', '..\\', '..'), '', $this_input_get_directory), '/');
} else {
$directory = DIR_IMAGE . 'catalog';
}
// Get directories
$directories = glob($directory . '/' . '*', GLOB_ONLYDIR);
if (!$directories) {
$directories = array();
}
// Get files
$files = array_reverse(glob($directory . '/' . '*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}', GLOB_BRACE));
if (!$files) {
$files = array();
}
// Merge directories and files
$images = array_merge($directories, $files);
$files_limit = 6;
$input_get_per_page = $this->input->get('per_page');
$input_get_per_page += $files_limit;
$config['base_url'] = base_url('filemanager');
$config['total_rows'] = count($images);
$config['per_page'] = $files_limit;
$config['page_query_string'] = TRUE;
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$data['images'] = array();
foreach ($images as $file => $value) {
$filename = str_replace(FCPATH . 'images/', '', $value);
$display_name = basename($filename);
if ($file < $input_get_per_page && $file >= $input_get_per_page - $files_limit) {
if (is_dir(DIR_IMAGE . $filename)) {
$data['images'][] = array(
'thumb' => '',
'type' => 'directory',
'path' => $value,
'name' => $display_name,
'href' => site_url('filemanager/' . $display_name)
);
} else if (is_file(DIR_IMAGE . $filename)) {
$data['images'][] = array(
'thumb' => $this->resize($filename),
'type' => 'image',
'path' => $value,
'name' => $display_name
);
}
}
}
$url = '';
if (isset($this_input_get_directory)) {
$pos = strrpos($this_input_get_directory, '/');
if ($pos) {
$url .= '?directory=' . urlencode(substr($this_input_get_directory, 0, $pos));
}
}
$data['parent'] = base_url('filemanager' . $url);
$url = '';
if (isset($this_input_get_directory)) {
$url .= '?directory=' . $this_input_get_directory;
}
$data['refresh'] = base_url('filemanager' . $url);
$this->load->view('template/common/filemanager_view', $data);
}
}

Dynamic title page category - Codeigninter

I'm trying to work on a website and would like to know
how to display the category name in the page title, favicon next to the page?
Example: Mysite - Category 1, Mysite - Category 2
Hello everyone, I'm trying to work on a website and would like to know
how to display the category name in the page title, favicon next to the page?
function cat() {
$offset = (int) $this->uri->segment(4);
$appcat_nome = xss_clean($this->uri->segment(3));
$categoria = $this->appcat->get(array('appcat_url' => $appcat_nome, 'appcat_status' => 1, ));
$this->data['titulo'] = 'Digital Feed';
$cond = array('app_on' => 1);
$this->data['apps2'] = $this->apps->getAll($cond, '', 1000, '', 'app_view DESC');
// Configurações do site.
$this->data['config_site'] = $this->config_site->getAll(array('conCod' => 1))->row();
if (count($categoria) == 1)
{
$where = array('A.appcat_id' => $categoria[0]['appcat_id']);
$total_rows = $this->apps->getAll($where)->num_rows();
$this->data['apps'] = $this->apps->getAll($where, $offset, $this->limit, '');
$this->load->library('pagination');
$config['base_url'] = base_url() . 'apps/cat/'. $appcat_nome . '/';
$config['total_rows'] = $total_rows;
$config['per_page'] = $this->limit;
$config['uri_segment'] = 4;
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->data['total_rows'] = $total_rows;
$this->pagination->initialize($config);
$this->data['pagination'] = $this->pagination->create_links();
$this->load->view('site/apps/index', $this->data);
}else{
redirect(base_url().'apps');
}
}
To set title to pages, pass title from controller.
$data["page_title"] = "Category 1";
In view file:
<?php
$title = "Mysite";
if(!empty($page_title))
$title .= " - ".$page_title;
?>
<title><?php echo $title;?></title>

Resources