how to remove the arrow mark from the pagiantion in codeigniter - codeigniter

In codeigniter Pagination ,I have the pagination links like below.
EG 1 : 1 2 3 > Last ›
EG 2 : ‹ First < 5 6 7 8 9 > Last ›
From the above link how to remove the ">" all arrow mark from the pagination link.
is any keyword set in config parameters.
My code :
public function index()
{
$limit = ($this->uri->segment(4) > 0)?$this->uri->segment(4):0;
$config['base_url'] =base_url().'/dep/index/';
$config["total_rows"] = sizeof($this->MODEL_NAME->COUNT_DEP($companyID, $sortBy, $orderBy));
$config['per_page'] =5;
$config['uri_segment'] = 4;
$config['next_link'] = '';
$config['prev_link'] = '';
$config['num_links'] = 2;
$data["CE"] = $this->MODEL_NAME->get_dep($dep_id, $sortBy, $orderBy,$config["per_page"], $limit);
$data["total_count"] = $config["total_rows"];
$this->pagination->initialize($config);
$data["links"] = $this->pagination->create_links();
$this->load->view('dep/home',$data);
}

You can do with following 4 options:
$config['next_link'] = '';
$config['prev_link'] = '';
$config['first_link'] = 'First';
$config['last_link'] = 'Last';

I want your code, but try this
$config['next_link'] = '';
$config['prev_link'] = '';

$config['next_link'] = '<img src="'.base_url().'backend/images/right-arrow.png" >';
$config['prev_link'] = '<img src="'.base_url().'backend/images/left-arrow.png" >';
$config['base_url'] = ''.base_url().'admin/home/userList/?id='.$id.'';
$config['uri_segment'] = 3;
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = TRUE;
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open']='<li><a href="[removed]void(0);" class="page_active">';
$config['cur_tag_close']='</a></li>';

Related

Getting the same data on pagination in Codeigniter

I am getting the same data when I am clicking on the next button of pagination in CodeIgniter with the following code
public function view($slug){
$data['title']= $slug;
$data['description']= "None";
$postdatacount = $this->Constant_model->snippettagscount($slug);
$checktags= $this->Constant_model->gettags($slug);
if($checktags>0){
if ($postdatacount>0) {
$config = array();
$config["base_url"] = base_url() ."tags/".$slug;
$config["total_rows"] = $postdatacount;
$config["per_page"] = 6;
$config["uri_segment"] = 2;
$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);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data["links"] = $this->pagination->create_links();
$data["title"] = "All Tags";
$data["description"] = "All Tags";
$data['snippets_tags'] = $this->Constant_model->get_tags($config["per_page"],$page,$slug);
$this->snippetfunctions->add_count('tags','tag_name',$slug);
$this->load->view('view_tag_snippets', $data);
}else {
$data["title"] = "No Snippet Found for this Tag";
$data["description"] = "No Snippet Found for this Tag";
$data["slug"] =$slug;
$this->load->view('error_tags',$data);
}
}else{
$this->load->view('404',$data);
}
}
Primary URL Made on this function is
http://127.0.0.1/Mytredin_codesup/tags/user-interface
When I am clicking on Next button following URL is made but not loading the next data but loading the same data and the same thing happens on every next page.
http://127.0.0.1/Mytredin_codesup/tags/user-interface/1
Routes I am using is
$route['tags/(:any)/(:num)'] = 'tags/view/$1/$2';
$route['tags/(:any)'] = 'tags/view/$1';
The problem is with the config $config["uri_segment"] = 2;, according to your routing the page variable is at segment 3.
Use $config["uri_segment"] = 3; instead of $config["uri_segment"] = 2;. Also change the line $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
More details read

codeigniter pagination with uri routing

My controller is flex and my function name is post_blog. I have done the routing for this function $config['blog'] = 'flex/post_blog'. Till this everything is working fine. I added pagination for the page which is loaded by above function and my $config['base_url'] = 'blog'. Everything is fine on my first page but on the second page it is showing page not found.
How do I solve this problem?
$this->load->library('pagination');
if($this->uri->segment(2)){
$page = ($this->uri->segment(2)) ;
}
else{
$page = 1;
}
$config = array();
$config['base_url'] = base_url('blog');
$config['total_rows'] = $post_count;
$config['per_page'] = 15;
$config['num_links'] = 2;
$config['use_page_numbers'] = TRUE;
$config['cur_tag_open'] = ' <a class="current"><b>';
$config['cur_tag_close'] = '</b></a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$offset=(($page-1)*$config["per_page"]) ;
$this->pagination->initialize($config);
$str_links = $this->pagination->create_links();
$data['links'] = explode(' ',$str_links );
Try
$config['base_url'] = base_url('controller_name/blog');
$config['uri_segment'] = 3;
Also remove echo $page;exit;
Try Changing $config['num_links'] = 2; to $config['num_links'] = $post_count;

codeigniter pagination not working when there is a query string

i'm using latest version of codeigniter(2.1.4).In admin when i'm sending query string then pagination not working.And i want my url will be like mydomain/commission/user_id/page_no.
ex: mydomain/commission/20/1
Below is my code
$config['per_page'] = 2;
$config['total_rows']=100;
$config['base_url'] = base_url().'admin_vendor/commissions/'.$this->uri->segment(3);
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = FALSE;
$config['enable_query_strings']=FALSE;
$config['num_links'] = 20;
$config['full_tag_open'] = '<ul>';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a>';
$config['cur_tag_close'] = '</a></li>';
$config['next_link'] = 'Next>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = '<Prev';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$page = $this->uri->segment(4);
$limit_end = ($page * $config['per_page']) - $config['per_page'];
if ($limit_end < 0){
$limit_end = 0;
}
please guide me. Thanks
go to application/config.php file
and change $config['enable_query_strings'] = FALSE; to
$config['enable_query_strings'] = TRUE;
It will work

Codeigniter adding anchor_class in pagination to the specified element

this is my first time with CI pagination and I can't find info how to add anchor_class to specified link. For example my last item in pagination, which called "NEXT" have class="last" but I don't know how to add class="last" only to this element. This is what I tried:
$config['base_url'] = site_url('page');
$config['total_rows'] = $this->news_job->countAllMods();
$config['per_page'] = '1';
$config['first_link'] = FALSE;
$config['last_link'] = FALSE;
$config['uri_segment'] = '2';
$config['full_tag_open'] = '<ul>';
$config['full_tag_close'] = '</ul>';
$config['next_link'] = 'Next';
$config['cur_tag_open'] = '<li class="button_pagination_nav button_graydark_nav"><a>';
$config['cur_tag_close'] = '</a></li> ';
$config['num_tag_open'] = '<li class="button_pagination_nav button_graylight_nav">';
$config['num_tag_close'] = '</li> ';
$config['next_tag_open'] = '<li class="button_pagination_nav button_graydark_nav">';
$config['anchor_class'] = 'class="last" ';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = 'Back';
$this->pagination->initialize($config);
so as You can see I'm using $config['anchor_class'] but with that all my pagination links gets class="last". So what should I do, to add class="last" only to next_tag_close?
I'm not sure but in codeigniter 3 this one works
$config['attributes'] = array('class' => 'last');
Try this:
$config['last_tag_open'] = '<li class="last_link">';
$config['last_tag_close'] = '</li>';
$(function(){
$(".last_link a").addClass('last');
});
Comment out this line:
$config['anchor_class'] = 'class="last" ';
$config['last_link'] = TRUE;
Here is some Reference

Codeigniter Pagination Need Solution - number link work but page doesnot display as appropriate

I have a problem with pagination in CodeIgniter 2.x
This is my code in Controller:
$config['base_url'] = base_url().'crawl/all/'.$file.'/';
$config['total_rows'] = $total;
$config['per_page'] = 10;
$config['num_links'] = 3;
$config['uri_segment'] = 4;
$config['full_tag_open'] = '<ul id="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open'] = '<li class="next">';
$config['next_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active">';
$config['cur_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$data['total'] = $total;
$data['path'] = $this->path.'/'.$file;
$data['file'] = $file;
$data['batch'] = $this->batch->all($file, $config['per_page'], $config['uri_segment']);
and my view is just: <?php echo $this->pagination->create_links() ?>
The links for pages numbers work (they move from 1 to 2 etc), but the data does not display correctly.
You are missed out the page id because when you clicks on the page the page no has to send as query string and it has to add for the config.
Example code:
$limit = $this->config->item('paging_limit');
$offset = $id * $limit;
$data['rows'] = $this->news_model->get_moreNews($limit, $offset);
$config["image_url"]=$this->config->item("base_url");
$config['base_url'] = base_url().'/news/morenews/';
$config['total_rows'] = $this->db->count_all('news');
$config['per_page'] = $limit;
$config['chapter'] = $this->input->post('chapter');
$config['page'] = $id;
$this->paginationsimple->initialize($config);
$paginator=$this->paginationsimple->create_links();
$data['paginator'] = $paginator;

Resources