Septanet Forum  

Go Back   Septanet Forum > Computers, Software, Harware, Information Technology > PHP Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-08-2011, 03:23 PM   #1
Senior Member
 
kaman's Avatar
 
Join Date: Aug 2011
Posts: 111
Smile Implementing Flicker Type Pagination into Codeigniter Application

If you are searching for good looking pagination feature to implement into your Codeigniter Application, then the Flicker Type Pagination function will be a right choice. It is very dynamic and easily customizable.

1.Download the pagination class file and put it under libraries.
http://www.septanet.com/attachment.p...1&d=1312537990

2.Copy and Paste below code into your controller which uses pagination functionality.

PHP Code:
<?php
$this
->load->library('paging');  //loading pagination library
$this->load->model('users_model'// loading model for SQL queries. 'users_model' is just example, you can replace it with your model name.

$per_page_rows 9//you can change it dynamically by allowing users to input number of pages.
$total_rows $this->users_model->count_users();
$current_page $this->uri->segment(n);
        if(!
$current_page){
            
$recStart 0;
        }
        else{
            
$recStart = ($current_page 1) * $per_page_rows;
        }

        
$keyword '';
        
$this->paging->limit($per_page_rows);
        
$this->paging->nextIcon('►');
        
$this->paging->prevIcon('◄');
        
$this->paging->changeClass("flickr");
        
$this->paging->Items($total_rows);
        
$this->paging->target(site_url('controller/search/' $keyword));
        
$this->paging->currentPage($current_page);
    
$this->load->view('users', array('users_list'=>$this->users_model->get_users($recStart$per_page_rows)));

?>
// NOTE: Please pass some values for above mentioned variables.
// $per_page_rows indicates numbers of records in a page
// $total_rows indicates total number of records returned by your query
// Search is a function where you are putting above code. When user clicks on hyperlinks (created by Pagination function), it takes users to the specified function in controller.
// $keyword – this is not required. You can just assign empty data for this variable.
// $current_page indicates the page which users currently opening. You can get it by using $this->uri->segment(n) function. Replace 'n' as per your routing setting.
// $recStart – this variable is used for LIMIT clause in SQL statement which indicates the starting record for any page. 0 indicates the starting record for first page.

// $this->users_model->count_users(); this function returns total number of users retrieved from database.
// $this->users_model->get_users($recStart, $per_page_rows)));
This function returns the number of records specified in $per_page_rows variable starting from $recStart position.

3.Copy and Paste below code into Views [e.g. users] where you would like to show pagination.

Code:
<div class="margtopb" align="center">
    <?php $this->paging->show(); ?>
</div>
4.Copy and Paste following codes into your CSS file.

Code:
/*Pagination Flickr style*/
div.flickr {
    padding: 3px;
    margin: 3px;
    text-align:center;
}

div.flickr a {
    border: 1px solid #cccccc;
    margin-right:3px;
    padding:2px 6px;
    background-position:bottom;
    text-decoration: none;
}
div.flickr a:hover, div.meneame a:active {
    border: 1px solid #000;
    background-image:none;
    background-color:#215DA2;
    color: #ffffff;
}
div.flickr span.current {
    margin-right:3px;
    padding:2px 6px;
    font-weight: bold;
    color: #ff0000;
    background-color:#ecf1f5;
    border: 1px solid #ff0000;
}
div.flickr span.disabled {
    margin-right:3px;
    padding:2px 6px;
    color: #adaaad;
}
div.margtopb{
    text-align: left;
}

/* End of Pagination style */
5. Copy and paste following codes into your Model file. [in this example the model name is 'users_model'].

PHP Code:
<?php
class Users_model extends CI_Model{
    function  
__construct() {
        
parent::__construct();        
    }

    function 
count_users(){
        
$query_count_users 'SELECT * FROM tbl_users';
        
$rsCountUsers $this->db->query($query_count_users );
        return 
$rsCountUsers->num_rows();
    }

    function 
get_users($startRec$per_page_recs){
        
$query_users 'SELECT * FROM tbl_users LIMIT '.$startRec.','$per_page_recs;
        
$rsUsers $this->db->query($query_users);
        return  
$rsUsers->result();
    }

?>
That's all. Good LUCK.

Your valuable feedback are always welcome.
Attached Files
File Type: zip paging.zip (2.2 KB, 0 views)
kaman is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Old 05-08-2011, 03:59 PM   #2
Senior Member
 
sachin's Avatar
 
Join Date: Aug 2011
Posts: 131
Default Nice tutorial

Very useful tutorial.

Thanks
sachin is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Old 05-08-2011, 04:02 PM   #3
Senior Member
 
kaman's Avatar
 
Join Date: Aug 2011
Posts: 111
Default

Thank you, Sir. My pleasure to share information through forum.
kaman is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Old 20-08-2011, 01:32 PM   #4
Senior Member
 
sharma.s.prakash's Avatar
 
Join Date: Aug 2011
Posts: 110
Default

Nice code help full!
sharma.s.prakash is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Old 20-08-2011, 01:41 PM   #5
Senior Member
 
kaman's Avatar
 
Join Date: Aug 2011
Posts: 111
Smile

Thnx Mr. Sharma.
kaman is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Reply

Tags
codeigniter pagination, flicker type pagination, pagination

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 12:57 PM.


Content Relevant URLs by vBSEO 3.5.0 RC2