ドキュメント

ページング処理

ActiveGatewayとPagerの連携

Samurai Frameworkでは、ActiveGatewayとPagerとの連携を強力にサポートしています。
component/action/samurai.dicon
Pager:
    class: Etc_Helper_Pager_Activegateway
    instance: prototype
AG:
    class: 'ActiveGatewayManager::getActiveGateway'
    args: ['base']
component/action/Some.class.php
class Action_Some extends Samurai_Action
{
    public $AG;
    public $Pager;
 
    public function execute()
    {
        $cond = $this->AG->getCondition();
        $cond->setLimit(10);
        $cond->setOffset($this->Request->get('page', 1));
        $records = $this->AG->findAllDetail('table', $cond);
        $this->Pager->init($records, $cond);
    }
}
template/some.tpl
...snip
 
{if $Pager->hasPrev()}
    <a href='{$Pager->appendQuery("page=`$Pager->prev`")}'>前へ</a>
{/if}
 
[
{foreach from=$Pager->sliding(10) item='page'}
    <a href='{$Pager->appendQuery("page=`$page`")}'>{$page}</a>
{/foreach}
]
 
{if $Pager->hasNext()}
    <a href='{$Pager->appendQuery("page=`$Pager->next`")}'>次へ</a>
{/if}
 
...snip

コメント

コメントはまだありません。
お名前
認証コード
本文