Paging

Navigation:  Development > Function Reference > Model >

Paging

Previous pageReturn to chapter overviewNext page

This function retrieve value like findAll function but it create a pagination based on a limit
 

App::Model(MODEL)->Paging(CONDITION,LIMIT,LINK); 
 

In CONDITION we can pass condition of WHERE clause as parameter of the function.

LIMIT is the number of entry per page. By default it set value from admin setting (Admin > Preferences >Site Setting)

LINK : We can pass a link to redirect the page in a particular link. If by default system set current URL

 

For example: 
$List = App::Model('Page')->paging("1 ORDER BY ID ASC",2); 
 
// Return value
/*[data] => Array

        (

         [0] => Array

                (

                    [id] => 1

                    [fkey] => 0

                    [page_title] => About appRain:  PHP Content  Management Framework | Content Management System | 

                    [meta_keywords] => About Content Management System, PHP Framework

                    [meta_description] => A PHP Content Management Framework

                    [name] => aboutus

                    [title] => About Us

                    [content] => appRain is one of the first officially released Open Source Content Management Framework (CMF).

                    [hook] => sitemenu,quicklinks

                    [userdefinehook] => 

                    [richtexteditor] => Yes

                    [rendertype] => smart_h_link

                    [contenttype] => Content

                )

 

            [1] => Array

                (

                    [id] => 2

                    [fkey] => 0

                    [page_title] => Terms of Use: appRain Content Management Framework

                    [meta_keywords] => Terms, Condition, Copy Right

                    [meta_description] => 

                    [name] => terms-of-use

                    [title] => Terms of Use

                    [content] => Copyright (c) appRain CMF (http://www.apprain.com)

                    [hook] => quicklinks,template_footer_B

                    [userdefinehook] => 

                    [richtexteditor] => Yes

                    [rendertype] => smart_h_link

                    [contenttype] => Content

                )            

        )

 

    [paging] => <a href="?&amp;page=2" class="page_next" title="Next">Next</a>

    [link] => Showing Results 1-2 of 15

    [total] => 15

    [page] => 1

    [paging_str] => <div class="pagination pagination-left">

        <div class="results"><span>Showing Results 1-2 of 15</span></div>

        <ul class="pager">

            <li class="disabled">Previous</li>

            <li class="current">1</li>
            <li><a href="?&page=2">2</a> </li>
            <li><a href="?&page=3">3</a></li>
            <li><a href="?&page=4">4</a> </li>
            <li><a href="?&page=5">5</a> </li>

            <li><a href="?&amp;page=2" class="page_next" title="Next">Next</a></li>

        </ul>

    </div>

)

*/

 

A common example to pass GET parameter:

$List = App::Model('Page')->paging("1 ORDER BY ID ASC",2,'?x=y'); 

 
In the above example pagination will generate like bellow
[paging] => <a href="?x=y&page=2" class="page_next" title="Next">Next</a>