Welcome Guest, Not a member yet? Register   Sign In
Page Navigation Helper
#1

[eluser]Adods[/eluser]
Page Navigation helper helps you to create Pagination or Page Navigation

Download (v0.2)

PageNav Parameters:
Quote:curpage* = current page - default 1
limit* = offset - default 10
total* = total data - default 0
first_text = 'First' Link Text
prev_text = 'Previous' Link Text
next_text = 'Next' Link Text
last_text = 'Last' Link Text
num_links = Number of links before and after the current page
full_class = CSS Class for Main Navigation
fnl_class = CSS Class for First and Last link
fnl_dis_class = CSS Class for Disabled First and Last link
pnn_class = CSS Class for Prev and Next Link
pnn_dis_class = CSS Class for Disabled Prev and Next Link
num_class = CSS Class for Page Number Links
cur_class = CSS Class for Current Page Number
limit_class = CSS Class for Limit Box
counter_class = CSS Class for Counter
counter_cur_class = Class for Current data on Counter
counter_total_class = Class for Total data on Counter

* Required

Example :
Controller :
Code:
class Home extends Controller {
    function Home() {
        parent::Controller();
        $this->load->helper('pagenav');
    }
    
    function index() {
        $params = GetPageNLimitVar();
        $params['total'] = $this->db->count_all('test');
        $pageNav = CreatePageNav($params);
        $data['pageNav'] = $pageNav;
        $data['rows'] = $this->db->get('test',$pageNav->limit,GetLimitStart($pageNav->curpage,$pageNav->limit));
        $this->load->view('layout',$data);
    }
}

view :
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Page Navigation Helper&lt;/title&gt;
&lt;?=$pageNav->AttachStyle();?&gt;
&lt;/head&gt;

&lt;body&gt;
<table width="100%" border="1" cellspacing="0" cellpadding="5" style="border-collapse:collapse;">
    <tr>
        <td>
        &lt;? foreach($rows->result() as $row): ?&gt;
        &lt;?=$row->data;?&gt;<br />
        &lt;? endforeach; ?&gt;
        &lt;?=$pageNav->Navigation(site_url('home/index'));?&gt;
        &lt;?=$pageNav->Counter();?&gt;
        Show : &lt;?=$pageNav->LimitBox(site_url('home/index'));?&gt; per page
        </td>
    </tr>
</table>
&lt;/body&gt;
&lt;/html&gt;

If you find some bugs or errors, please feel free to post it ;-)
comment please Smile
#2

[eluser]xwero[/eluser]
If i understand it the constants are url segement that identify the pagenumber and the offset. I think you better use a config array that way you can make multi language urls and they are only known in the scope of the helper.
#3

[eluser]Adods[/eluser]
ahhh, yes. thanks.

PageNav v.0.2
Download
Code:
* added configuration file to set default parameter for page and offset name
* added new config variabel to set default text for Counter

Example : see first post

again, suggestion please ;-)
#4

[eluser]nearo[/eluser]
Thank you for this helpful bit of code. I did have to change
Code:
$segments = $CI->uri->segments;
to
Code:
$segments = $CI->uri->segment_array();
in your GetPageNLimitVar function for it to work for me.
#5

[eluser]Unknown[/eluser]
I have a problem when using function Page Navigation helper:

Fatal error: Call to undefined function GetPageNLimitVar()

Please help me. Thank so much!




Theme © iAndrew 2016 - Forum software by © MyBB